ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop Through textbox in Excel (https://www.excelbanter.com/excel-programming/351322-loop-through-textbox-excel.html)

sweet

Loop Through textbox in Excel
 
Hi,

I have around 30 textboxes in my Excel 2003. and were created by
=EMBED("Forms.TextBox.1","")

I wonder how I can loop through them using VB within Excel. I have
tried
1. me.controls
2.msforms.textbox
3.OLEObjects

But none of them seems to work. Can you please let me know the syntax
so that I can get each textbox through a loop?

Thanks in advance. Your advice and help would be greatly appreciated.


Tom Ogilvy

Loop Through textbox in Excel
 
Dim obj as OleObject
Dim tbox as MSForms.TextBox
for each obj in ActiveSheet.OleObjects
if typeof obj.Object is MSforms.TextBox then
set tbox = obj.Object
msgbox tbox.Name & " - " & tbox.Value
end if
Next

--
Regards,
Tom Ogilvy

"sweet" wrote in message
ups.com...
Hi,

I have around 30 textboxes in my Excel 2003. and were created by
=EMBED("Forms.TextBox.1","")

I wonder how I can loop through them using VB within Excel. I have
tried
1. me.controls
2.msforms.textbox
3.OLEObjects

But none of them seems to work. Can you please let me know the syntax
so that I can get each textbox through a loop?

Thanks in advance. Your advice and help would be greatly appreciated.





All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com