We are needing to get some information from a table on a web page at Amazon. It is easy enough to copy and paste it into Excel. However, some of the important data comes in a textbox. I want to extract that data and put it into the cell above the text box. I’ve tried VBA subs and formulas in the cell where I want the data to go but nothing seems to be working. With two cells, I want to take the data out of the bottom one which contains the textbox and put it into the top one and eventually merge the two cells to get rid of the texbox. Can anyone point me in the right direction?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Text box value from a web page copy and paste
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Text box value from a web page copy and paste
- This topic has 17 replies, 6 voices, and was last updated 9 years, 10 months ago.
Viewing 8 reply threadsAuthorReplies-
Paul T
AskWoody MVP -
WSjpzinn
AskWoody LoungerJuly 2, 2015 at 8:44 am #1513154Here is a sample of just the two cells. I want to take the value out of the textbox that is in A2 and put it into A1.
I will have several thousand of these to do or I could just type the value in…41236-TextboxExample
-
-
WSjpzinn
AskWoody LoungerJuly 4, 2015 at 1:41 pm #1513579No one has any ideas on how to get the value of the textbox? I’ve tried everything I can think of. From the above example, I’ve tried things like:
MsgBox (Range(“A2”).Value) – I get a blank message box
MsgBox (HTMLText1.Value) – I get a blank message box
MsgBox (HTMLText1.Text) – I get a blank message box
MsgBox (ActiveSheet.Shapes(“HTMLText1”).Text) – I get a message – “The item with the specified name wasn’t found.”
Various other ideas have resulted in blanks. I want to put the value into cell A1 like Range(“A1”).Value = HTMLText1.Text but that isn’t working so I tried the message box just to see if I could get the value and I can’t do it.I’ve never asked a question here before where the answer wasn’t available. I’ve done a lot of searching on the internet and can’t find an answer. I can’t imagine that this is too much for you Excel gurus.
-
zeddy
AskWoody_MVPJuly 4, 2015 at 4:35 pm #1513585Hi
This code will put the values into column in the corresponding row. Adjust as required.
Code:Sub getValues() Set zSht = ActiveSheet With zSht For Each Z In .OLEObjects If TypeOf Z.Object Is msforms.TextBox Then r = Z.TopLeftCell.Row Cells(r, "B").Value = Z.Object.Value End If Next Z End With End Sub
zeddy
Polo Instructor
-
-
access-mdb
AskWoody MVP -
WSjpzinn
AskWoody LoungerJuly 4, 2015 at 7:10 pm #1513665That looks great but when I run it, I get a message saying, “Unable to get the TopLeftCell property of the OLEObject class”. I wonder if the textbox pasted from a web page is an OLEObject. When I look at the properties of the textbox from the developer tab in design mode, it says “HTMLText1 HTMLText” at the top in the combobox that contains the list of objects on the sheet.
I had not tried to paste the web information into Notepad+ but have since tried that and it does not include either the textbox or the value in it when I paste it there.
-
WSpstraton
AskWoody Lounger -
WSpstraton
AskWoody LoungerAugust 11, 2015 at 11:38 am #1521730I get a message saying, “Unable to get the TopLeftCell property of the OLEObject class”.
I have seen the “Unable to get the TopLeftCell property of the OLEObject class” error as a result of Excel’s VBE getting confused and, apparently, compiling the code incorrectly. Save the file, re-open it, and the problem should go away.
-
-
WSjpzinn
AskWoody LoungerJuly 4, 2015 at 8:54 pm #1513675I finally got it to work. My code is very similar to the suggestion from Zeddy but there are some differences. Nonetheless, thanks to all who contributed. Apparently there are two types of textboxes that can be in Excel – one from the Drawing toolbar, and one from the control toolbox toolbar (these happened to be the latter). My solution is below:
Dim OLEObj As OLEObject ‘from the control toolbox toolbar
Dim DestCell As Range
Dim wks As Worksheet
Set wks = ActiveSheet
With wks
For Each OLEObj In .OLEObjects
If TypeOf OLEObj.Object Is msforms.TextBox Then
Set DestCell = OLEObj.TopLeftCell.Offset(-1, 0)
DestCell.Value = OLEObj.Object.Value
End If
Next OLEObj
End With -
zeddy
AskWoody_MVP
-
-
WSjpzinn
AskWoody Lounger -
zeddy
AskWoody_MVPJuly 6, 2015 at 5:34 am #1513787Hi
As TopLeftCell is used in both routines I guess it was a typo.
If you want to delete the boxes after getting the values, you could use code like this:
Code:Sub getValues() Set zSht = ActiveSheet 'define shortcut With zSht 'use shortcut For Each zBox In .OLEObjects 'loop through all ActiveX controls on sheet If TypeOf zBox.Object Is MSForms.TextBox Then 'check control type r = zBox.TopLeftCell.Row 'control is on this row number Cells(r, "A").Value = zBox.Object.Value 'put value into column A, then.. zBox.Delete '..delete the control End If 'end of test for control type Next zBox 'process next control End With 'end of shortcut End Sub
see attached example file
zeddy
•Toast Quality Assurance Manager -
WSjpzinn
AskWoody Lounger
-
-
-
Maudibe
AskWoody_MVP -
Maudibe
AskWoody_MVPJuly 6, 2015 at 10:15 pm #1513994JP,
By looking at the source code from the webpage, you can determine the “id” of the textbox then extract the data. You can place a webBrowser control in your workbook to open the URL then use the following line of code to extract the value
Range(“A1”)=WebBrowser1.Document.getelementbyid(“idName”).Value where idName is the id name you found in the source code.
The entire code might look something like this:
Code:Private Sub GetValue() [COLOR=”#008000″]’———————————- ‘NAVIGATE TO URL[/COLOR] WebBrowser1.Visible = True WebBrowser1.Navigate2 “https://NameOfWebite.com” Do DoEvents Loop Until WebBrowser1.ReadyState = 4 [COLOR=”#008000″]’———————————- ‘COPY TEXTBOX VALUE TO CELL A1[/COLOR] Range(“A1”) = WebBrowser1.Document.getelementbyid(“IDnAME”).Value End Sub
Note that you will need to reference Microsoft Internet Controls in the VB editor
Tools > Refernces > Microsoft Internet Controls > OKThe control is added to the worksheet from Developer tab > Insert > … > Microsoft Web Browser
HTH,
Maud -
Maudibe
AskWoody_MVPJuly 6, 2015 at 10:21 pm #1513995I did delete the boxes and there were also some checkboxes and comboboxes on the worksheet so I just deleted all the objects.
Btw, the following snippet will delete all the objects on the active sheet instead of manually deleting them.
Code:ActiveSheet.DrawingObjects.Select Selection.Cut
Maud
Viewing 8 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
33 minutes ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
1 hour, 39 minutes ago -
Disengage Bitlocker
by
CWBillow
3 hours, 3 minutes ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
3 hours, 38 minutes ago -
New Win 11 Pro Geekom Setup questions
by
Deo
5 hours, 23 minutes ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
10 hours, 54 minutes ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
10 hours, 55 minutes ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
14 hours, 50 minutes ago -
New PC transfer program recommendations?
by
DaveBoston
5 hours, 11 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
18 hours, 55 minutes ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
18 hours, 56 minutes ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
7 hours, 15 minutes ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
4 hours, 37 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
17 hours, 5 minutes ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
1 day, 13 hours ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
11 hours, 49 minutes ago -
System Restore and Updates Paused
by
veteran
1 day, 16 hours ago -
Windows 10/11 clock app
by
Kathy Stevens
1 day, 3 hours ago -
Turn off right-click draw
by
Charles Billow
1 day, 19 hours ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
1 day, 23 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
17 hours, 4 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
2 days ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
1 day, 3 hours ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
2 days, 6 hours ago -
KB5060842 Issue (Minor)
by
AC641
18 hours, 54 minutes ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
2 days, 13 hours ago -
24H2 may not be offered June updates
by
Susan Bradley
1 day, 6 hours ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
3 days, 2 hours ago -
June 2025 updates are out
by
Susan Bradley
7 hours, 55 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
3 days, 17 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.