ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable in object name (https://www.excelbanter.com/excel-programming/323831-variable-object-name.html)

kaptenn

variable in object name
 
I have checkboxes with names from checkbox1 to checkbox20
if I try
sub whatever()
for i=1 to 20
if checkbox(i).value=true then
do sumething
end if
next i
end sub
I get error message that sub or function not defined. How to fix that?

Tom Ogilvy

variable in object name
 
sub whatever()
for i=1 to 20
if Activesheet.OleObjects("checkbox" & i).value=true then
do sumething
end if
next i
end sub

would be an example for a checkbox from the control toolbox toolbar where
the checkboxes have names like checkbox1 to checkbox20. You haven't said
where it is from or where it is located.

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
I have checkboxes with names from checkbox1 to checkbox20
if I try
sub whatever()
for i=1 to 20
if checkbox(i).value=true then
do sumething
end if
next i
end sub
I get error message that sub or function not defined. How to fix that?




kaptenn

variable in object name
 
These checkboxes are located in userform

"Tom Ogilvy" wrote:

sub whatever()
for i=1 to 20
if Activesheet.OleObjects("checkbox" & i).value=true then
do sumething
end if
next i
end sub

would be an example for a checkbox from the control toolbox toolbar where
the checkboxes have names like checkbox1 to checkbox20. You haven't said
where it is from or where it is located.

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
I have checkboxes with names from checkbox1 to checkbox20
if I try
sub whatever()
for i=1 to 20
if checkbox(i).value=true then
do sumething
end if
next i
end sub
I get error message that sub or function not defined. How to fix that?





Tom Ogilvy

variable in object name
 
sub whatever()
for i=1 to 20
if Userform1.Controls("checkbox" & i).value=true then
do sumething
end if
next i
end sub

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
These checkboxes are located in userform

"Tom Ogilvy" wrote:

sub whatever()
for i=1 to 20
if Activesheet.OleObjects("checkbox" & i).value=true then
do sumething
end if
next i
end sub

would be an example for a checkbox from the control toolbox toolbar

where
the checkboxes have names like checkbox1 to checkbox20. You haven't

said
where it is from or where it is located.

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
I have checkboxes with names from checkbox1 to checkbox20
if I try
sub whatever()
for i=1 to 20
if checkbox(i).value=true then
do sumething
end if
next i
end sub
I get error message that sub or function not defined. How to fix that?







kaptenn

variable in object name
 
Thanks a lot. And my task continues :)

"Tom Ogilvy" wrote:

sub whatever()
for i=1 to 20
if Userform1.Controls("checkbox" & i).value=true then
do sumething
end if
next i
end sub

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
These checkboxes are located in userform

"Tom Ogilvy" wrote:

sub whatever()
for i=1 to 20
if Activesheet.OleObjects("checkbox" & i).value=true then
do sumething
end if
next i
end sub

would be an example for a checkbox from the control toolbox toolbar

where
the checkboxes have names like checkbox1 to checkbox20. You haven't

said
where it is from or where it is located.

--
Regards,
Tom Ogilvy

"kaptenn" wrote in message
...
I have checkboxes with names from checkbox1 to checkbox20
if I try
sub whatever()
for i=1 to 20
if checkbox(i).value=true then
do sumething
end if
next i
end sub
I get error message that sub or function not defined. How to fix that?








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

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