ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting Controls in a sheet (https://www.excelbanter.com/excel-programming/295182-counting-controls-sheet.html)

Vikram Kohli

Counting Controls in a sheet
 
Hi

I want to know the number of textboxes that is placed on a sheet, and their names. How can i get the data from each control at runtime as i don't know how many controls are placed on that particular sheet?

Thanks

Tom Ogilvy

Counting Controls in a sheet
 
form the drawing toolbar

msgbox activesheet.Textboxes.count

for control toolbox toolbar textboxes

Dim cnt as long, obj as OleObject
cnt = 0
for each obj in Activesheet.OleObjects
if type of obj.Object is MSforms.Textbox then
cnt = cnt + 1
end if
Next
msgbox cnt

--
Regards,
Tom Ogilvy

"Vikram Kohli" wrote in message
...
Hi,

I want to know the number of textboxes that is placed on a sheet, and

their names. How can i get the data from each control at runtime as i don't
know how many controls are placed on that particular sheet?

Thanks




Bob Phillips[_6_]

Counting Controls in a sheet
 
Hi Vikram,

This should help

Dim i As Long
Dim OLEObject As Object

For Each OLEObject In ActiveSheet.OLEObjects
If TypeOf OLEObject.Object Is MSForms.TextBox Then
i = i + 1
End If
Next OLEObject
MsgBox i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vikram Kohli" wrote in message
...
Hi,

I want to know the number of textboxes that is placed on a sheet, and

their names. How can i get the data from each control at runtime as i don't
know how many controls are placed on that particular sheet?

Thanks





All times are GMT +1. The time now is 08:53 AM.

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