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, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
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
-
MS-DEFCON 3: Businesses must tread carefully
by
Susan Bradley
1 hour, 5 minutes ago -
McLaren Health Care says data breach impacts 743,000 patients
by
Nibbled To Death By Ducks
9 hours, 13 minutes ago -
WhatsApp banned on House staffers’ devices
by
Alex5723
4 hours, 14 minutes ago -
Is your device eligible?
by
Susan Bradley
12 hours, 12 minutes ago -
Windows 11 Insider Preview build 26200.5661 released to DEV
by
joep517
18 hours, 23 minutes ago -
Windows 11 Insider Preview build 26120.4452 (24H2) released to BETA
by
joep517
18 hours, 25 minutes ago -
Hello Windows…My Problem is Windows Hello…
by
rdleib
19 hours, 40 minutes ago -
New Canon Printer Wants Data Sent
by
Win7and10
19 hours, 58 minutes ago -
I set up passkeys for my Microsoft account
by
Lance Whitney
9 hours, 28 minutes ago -
AI is for everyone
by
Peter Deegan
19 hours, 31 minutes ago -
Terabyte update 2025
by
Will Fastie
13 hours, 34 minutes ago -
Migrating from Windows 10 to Windows 11
by
Susan Bradley
9 hours, 7 minutes ago -
Lost sound after the upgrade to 24H2?
by
Susan Bradley
1 day, 18 hours ago -
How to move 10GB of data in C:\ProgramData\Package Cache ?
by
Alex5723
1 hour, 39 minutes ago -
Plugged in 24-7
by
CWBillow
1 day, 4 hours ago -
Netflix, Apple, BofA websites hijacked with fake help-desk numbers
by
Nibbled To Death By Ducks
2 days, 7 hours ago -
Have Copilot there but not taking over the screen in Word
by
CWBillow
2 days, 5 hours ago -
Windows 11 blocks Chrome 137.0.7151.68, 137.0.7151.69
by
Alex5723
3 days, 23 hours ago -
Are Macs immune?
by
Susan Bradley
14 hours, 33 minutes ago -
HP Envy and the Function keys
by
CWBillow
3 days, 6 hours ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
1 day ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
4 days, 10 hours ago -
Unable to update to version 22h2
by
04om
1 day, 18 hours ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
4 days, 18 hours ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
4 days, 18 hours ago -
Very Quarrelsome Taskbar!
by
CWBillow
4 days, 3 hours ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
5 days, 7 hours ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
4 days, 19 hours ago -
Is your battery draining?
by
Susan Bradley
1 day, 1 hour ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
1 day, 19 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.