View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Object Required Error

Marvin,
In the first routine, you are referring to the object as an item in a
collection:
ActiveSheet.Shapes("PC 1")

In the second, you are referring to the object directly:
[PC 1] = xlOff

This second method is not a string, so you cannot build it up.
Use the first method in a loop. And the .select is not required.

Dim I as long

For I = 1 to 30
With ActiveSheet.Shapes("PC " & i)
.Value = xlOff
.LinkedCell = ""
.Display3DShading = True
End With
Next

NickHK

"Marvin" wrote in message
...
I have a series of 30 check boxes with the designation of...
ActiveSheet.Shapes("PC 1").Select
With Selection
.Value = xlOff
.LinkedCell = ""
.Display3DShading = True
End With
I found that I could replace the above code with just....
[PC 1] = xlOff
[PC 2] = xlOff....etc
I then tried to use a For/Next Loop to turn off all 30 boxes with ....
For I = 1 to 30
["PC "&I] = xlOff
Next I
This failed with a message that says object required. Any Thoughts.....