Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change buttoncolor on button on a sheet from VBA
Button1.BackColor = &H8000& works ok, but if I make a loop like this
for I = I to 10 if <argument true then ("Button" & cstr(I)).BackColor = &H8000 end if next I get this error: Expected : Linenumber or Label or statement or end of statement how should I call my Button I tried with: sheets("sheet1"). ("Button" & cstr(I)).BackColor = &H8000 sheet1. ("Button" & cstr(I)).BackColor = &H8000 activesheet. ("Button" & cstr(I)).BackColor = &H8000 .... and a lot of others |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change buttoncolor on button on a sheet from VBA
When you reference "button1" as in your first example which works, you are referencing an object. In the non-working other examples you are referencing text, which you can't set to a value.
Try (if the buttons are on a form) <formname.Controls("Button" & cstr(I)) or if they are on a sheet: <sheetname.Controls("Button" & cstr(I)) "akyhne" wrote: Button1.BackColor = &H8000& works ok, but if I make a loop like this for I = I to 10 if <argument true then ("Button" & cstr(I)).BackColor = &H8000 end if next I get this error: Expected : Linenumber or Label or statement or end of statement how should I call my Button I tried with: sheets("sheet1"). ("Button" & cstr(I)).BackColor = &H8000 sheet1. ("Button" & cstr(I)).BackColor = &H8000 activesheet. ("Button" & cstr(I)).BackColor = &H8000 ... and a lot of others |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change buttoncolor on button on a sheet from VBA
I always call my Controls in Forms with me.Controls or <Formname.Controls, but this simply doesn't work on Sheets
"Ian Digby" skrev: When you reference "button1" as in your first example which works, you are referencing an object. In the non-working other examples you are referencing text, which you can't set to a value. Try (if the buttons are on a form) <formname.Controls("Button" & cstr(I)) or if they are on a sheet: <sheetname.Controls("Button" & cstr(I)) "akyhne" wrote: Button1.BackColor = &H8000& works ok, but if I make a loop like this for I = I to 10 if <argument true then ("Button" & cstr(I)).BackColor = &H8000 end if next I get this error: Expected : Linenumber or Label or statement or end of statement how should I call my Button I tried with: sheets("sheet1"). ("Button" & cstr(I)).BackColor = &H8000 sheet1. ("Button" & cstr(I)).BackColor = &H8000 activesheet. ("Button" & cstr(I)).BackColor = &H8000 ... and a lot of others |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change buttoncolor on button on a sheet from VBA
sheet1.OLEObjects("Button" & cstr(I)).Object.BackColor = &HFF& works
"akyhne" skrev: I always call my Controls in Forms with me.Controls or <Formname.Controls, but this simply doesn't work on Sheets "Ian Digby" skrev: When you reference "button1" as in your first example which works, you are referencing an object. In the non-working other examples you are referencing text, which you can't set to a value. Try (if the buttons are on a form) <formname.Controls("Button" & cstr(I)) or if they are on a sheet: <sheetname.Controls("Button" & cstr(I)) "akyhne" wrote: Button1.BackColor = &H8000& works ok, but if I make a loop like this for I = I to 10 if <argument true then ("Button" & cstr(I)).BackColor = &H8000 end if next I get this error: Expected : Linenumber or Label or statement or end of statement how should I call my Button I tried with: sheets("sheet1"). ("Button" & cstr(I)).BackColor = &H8000 sheet1. ("Button" & cstr(I)).BackColor = &H8000 activesheet. ("Button" & cstr(I)).BackColor = &H8000 ... and a lot of others |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change caption of a button | Excel Worksheet Functions | |||
how to change formula in shared sheet without loss of change histo | Excel Worksheet Functions | |||
How do I create a command button to jump from sheet to sheet in a. | Excel Worksheet Functions | |||
Change workbook sheet reference using cell A1 to change a vairable | Excel Worksheet Functions | |||
Pause macro, add form button to sheet, continue macro when button clicked! | Excel Programming |