Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I'm programming a Macro to hide/unhide some entire rows and colums, but the following proble occurs: When I add the following script to the option button from controls, it displays an error in line 3 (in the example marked with *): Private Sub OptionButton1_Change() If OptionButton1.Value = True Then Sheets("Voorbeeldportefeuille").Select *Columns("H:K").Select* Selection.EntireColumn.Hidden = False Else Sheets("Invoer").Select End If End Sub When I use the option button from the Forms toolbar, I get the following script after recording the macro, and it works perfectly: Sub Keuzerondje25_BijKlikken() (- = Sub Optionbutton25_Click()) Sheets("Voorbeeldportefeuille").Select Columns("H:K").Select Selection.EntireColumn.Hidden = False End Sub Great that it works, but I want to use the option button from the controls toolbar, as I need to use the change function, in stead of the click function. Can anyone tell me what I'm doing wrong? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sheets("Voorbeeldportefeuille").Select
*Columns("H:K").Select* You need to qualify Columns("H:K") with the sheet reference. Normally without the reference the activesheet is implied, but as your code is in a worksheet module the code tries to select those columns in its own sheet. But it can't because it's no longer active. Instead try Sheets("Voorbeeldportefeuille").Columns("H:K").Sel ect Actually you really don't need to select, simply Sheets("Voorbeeldportefeuille").Columns("H:K").Ent ireColumn.Hidden = False (you don't even need to activate the sheet to do the above) Regards, Peter T If the worksheet module with your code does not "Voorbeeldportefeuille" you will need t "CalamityJane" wrote in message ... Hello, I'm programming a Macro to hide/unhide some entire rows and colums, but the following proble occurs: When I add the following script to the option button from controls, it displays an error in line 3 (in the example marked with *): Private Sub OptionButton1_Change() If OptionButton1.Value = True Then Sheets("Voorbeeldportefeuille").Select *Columns("H:K").Select* Selection.EntireColumn.Hidden = False Else Sheets("Invoer").Select End If End Sub When I use the option button from the Forms toolbar, I get the following script after recording the macro, and it works perfectly: Sub Keuzerondje25_BijKlikken() (- = Sub Optionbutton25_Click()) Sheets("Voorbeeldportefeuille").Select Columns("H:K").Select Selection.EntireColumn.Hidden = False End Sub Great that it works, but I want to use the option button from the controls toolbar, as I need to use the change function, in stead of the click function. Can anyone tell me what I'm doing wrong? Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works perfectly. Thanks for clarifying the difference, I'll keep it in mind.
"Peter T" wrote: Sheets("Voorbeeldportefeuille").Select *Columns("H:K").Select* You need to qualify Columns("H:K") with the sheet reference. Normally without the reference the activesheet is implied, but as your code is in a worksheet module the code tries to select those columns in its own sheet. But it can't because it's no longer active. Instead try Sheets("Voorbeeldportefeuille").Columns("H:K").Sel ect Actually you really don't need to select, simply Sheets("Voorbeeldportefeuille").Columns("H:K").Ent ireColumn.Hidden = False (you don't even need to activate the sheet to do the above) Regards, Peter T If the worksheet module with your code does not "Voorbeeldportefeuille" you will need t "CalamityJane" wrote in message ... Hello, I'm programming a Macro to hide/unhide some entire rows and colums, but the following proble occurs: When I add the following script to the option button from controls, it displays an error in line 3 (in the example marked with *): Private Sub OptionButton1_Change() If OptionButton1.Value = True Then Sheets("Voorbeeldportefeuille").Select *Columns("H:K").Select* Selection.EntireColumn.Hidden = False Else Sheets("Invoer").Select End If End Sub When I use the option button from the Forms toolbar, I get the following script after recording the macro, and it works perfectly: Sub Keuzerondje25_BijKlikken() (- = Sub Optionbutton25_Click()) Sheets("Voorbeeldportefeuille").Select Columns("H:K").Select Selection.EntireColumn.Hidden = False End Sub Great that it works, but I want to use the option button from the controls toolbar, as I need to use the change function, in stead of the click function. Can anyone tell me what I'm doing wrong? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Insert comments on Option Button of Forms Toolbar | Excel Discussion (Misc queries) | |||
Option Button on Forms Toolbar | Excel Discussion (Misc queries) | |||
RefEdits and normal forms / forms in a DLL | Excel Programming | |||
Option Button Macro (Forms Toolbar) | Excel Programming | |||
Option Button and forms | Excel Programming |