LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default variable help....

You are dealing with objects here, it just doesn't wotk that you can refer
to them partially and with variables.

You also missed soomething else I added in the code, albeiet I was not
explicit, so compare this code to yours

Sub CheckBox359_Click()
i = 359
If Controls("CheckBox" & i) Then
Sheets("Order_Entry").Shapes("Rectangle " & i).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 8
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Else
Sheets("Order_Entry").Shapes("Rectangle " & i).Select
Selection.ShapeRange.Fill.Visible = msoFalse
End If
End Sub

or even

Sub CheckBox359_Click()
i = 359
If Controls("CheckBox" & i) Then
With Sheets("Order_Entry").Shapes("Rectangle " & i) _
.ShapeRange.Fill.ForeColor.SchemeColor = 8
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Fill.Solid
End With
Else
Sheets("Order_Entry").Shapes("Rectangle " & i) _
.ShapeRange.Fill.Visible = msoFalse
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"ltyson" wrote in
message ...

Bob thank you. The one word 'controls' was the missing peice. This new
code pasted below now works perfect:

Sub CheckBox359_Click()
i = 359
If Controls("CheckBox" & i) = True Then
Sheets("Order_Entry").Shapes("Rectangle " & i).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 8
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
End If
If Controls("CheckBox" & i) = False Then
Sheets("Order_Entry").Shapes("Rectangle " & i).Select
Selection.ShapeRange.Fill.Visible = msoFalse
End If
End Sub

It is odd to me why i have to use:

If Controls("CheckBox" & i) = True Then

if I use the variable but:

if Checkbox359 = True Then

works fine if I don't use the variable. Looks like I have more
learning to do. :)

Thanks for your help,

Larry


--
ltyson
------------------------------------------------------------------------
ltyson's Profile:

http://www.excelforum.com/member.php...fo&userid=2768
View this thread: http://www.excelforum.com/showthread...hreadid=397581





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"