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, 9 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
-
DBOS Advanced Network Analysis
by
Kathy Stevens
1 minute ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
44 minutes ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 hours, 42 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
3 hours, 24 minutes ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 hour, 47 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
4 hours, 19 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
12 hours, 11 minutes ago -
Sometimes I wonder about these bots
by
Susan Bradley
8 hours, 28 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 1 hour ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
1 day, 2 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 1 hour ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
22 hours, 3 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
1 day, 4 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
1 day, 4 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
17 hours, 26 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
1 day, 12 hours ago -
0Patch, where to begin
by
cassel23
1 day, 7 hours ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
2 days, 2 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
1 day, 14 hours ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
2 days, 11 hours ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
2 days, 2 hours ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
1 day, 13 hours ago -
Installer program can’t read my registry
by
Peobody
6 hours, 4 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
1 day, 23 hours ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
2 days, 7 hours ago -
False error message from eMClient
by
WSSebastian42
2 days, 22 hours ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
3 days, 7 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
3 days, 8 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
6 hours, 9 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
3 days, 12 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.