Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to run a macro based on one or both value(s) of 2
checkboxes else I want to skip the macro. If chkbx1 is TRUE, I want to skip the macro. If chkbx2 is TRUE, I want to skip to skip the macro. If chkbx1 and chkbx2 are both TRUE, I want to skip the macro. This is what I have and it is not working (E6 and E7 are the cells linked to the checkbox controls.... Sub test() Worksheets("Data").Select Range("E6").Select If E6 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select ElseIf E7 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End Sub Thanks for any advice you may have! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Kathryn,
I believe that your code is looking for the word 'True' in the cell. True is really minus 1 and false is zero. I havn't tried it but you could try omitting the speech marks from around "True" which I think Excel will then interpret correctly trev -----Original Message----- I want to run a macro based on one or both value(s) of 2 checkboxes else I want to skip the macro. If chkbx1 is TRUE, I want to skip the macro. If chkbx2 is TRUE, I want to skip to skip the macro. If chkbx1 and chkbx2 are both TRUE, I want to skip the macro. This is what I have and it is not working (E6 and E7 are the cells linked to the checkbox controls.... Sub test() Worksheets("Data").Select Range("E6").Select If E6 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select ElseIf E7 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End Sub Thanks for any advice you may have! . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Kathryn,
Try this With Worksheets("Data") If .CheckBoxes("Check Box 1").Value = xlOn Or .CheckBoxes("Check Box 2").Value = xlOn Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End With which doesn't use the linked cells, or With Worksheets("Data") If .Range("E6") Or .Range("E7") Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End With which does. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Kathryn" wrote in message ... I want to run a macro based on one or both value(s) of 2 checkboxes else I want to skip the macro. If chkbx1 is TRUE, I want to skip the macro. If chkbx2 is TRUE, I want to skip to skip the macro. If chkbx1 and chkbx2 are both TRUE, I want to skip the macro. This is what I have and it is not working (E6 and E7 are the cells linked to the checkbox controls.... Sub test() Worksheets("Data").Select Range("E6").Select If E6 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select ElseIf E7 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End Sub Thanks for any advice you may have! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, Trev and AA2e72E ~
Thank you all for your help. I couldn't get any of them to work on their own for some reason but with a little trial and error, I came up with the following which is working just great. Sub mcrSaveAs() ' ' mcrSaveAs Macro ' Macro written 12/31/03 by Kathryn T ' ' Saves workbook as HC&DCReimburse_EE Name_Today's Date ' unless resubmission ' With Worksheets("Data") If .Range("E6").Value = True Or .Range("E7").Value = True Then Worksheets("Form").Select Range("A4:I4").Select Else ActiveWorkbook.SaveAs ("C:\My Documents\HC&DCReimburse#" & Sheets("Form").Cells(2, 8).Value & "_" & Sheets("Form").Cells(6, 6).Value & "_" & Sheets("Data").Cells(2, 5).Value & ".xls") End If End With End Sub Thanks Again! K -----Original Message----- I want to run a macro based on one or both value(s) of 2 checkboxes else I want to skip the macro. If chkbx1 is TRUE, I want to skip the macro. If chkbx2 is TRUE, I want to skip to skip the macro. If chkbx1 and chkbx2 are both TRUE, I want to skip the macro. This is what I have and it is not working (E6 and E7 are the cells linked to the checkbox controls.... Sub test() Worksheets("Data").Select Range("E6").Select If E6 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select ElseIf E7 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End Sub Thanks for any advice you may have! . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, Trev and AA2e72E ~
Thank you all for your help. I couldn't get any of them to work on their own for some reason but with a little trial and error, I came up with the following which is working just great. Sub mcrSaveAs() ' ' mcrSaveAs Macro ' Macro written 12/31/03 by Kathryn T ' ' Saves workbook as HC&DCReimburse_EE Name_Today's Date ' unless resubmission ' With Worksheets("Data") If .Range("E6").Value = True Or .Range("E7").Value = True Then Worksheets("Form").Select Range("A4:I4").Select Else ActiveWorkbook.SaveAs ("C:\My Documents\HC&DCReimburse#" & Sheets("Form").Cells(2, 8).Value & "_" & Sheets("Form").Cells(6, 6).Value & "_" & Sheets("Data").Cells(2, 5).Value & ".xls") End If End With End Sub Thanks Again! K -----Original Message----- I want to run a macro based on one or both value(s) of 2 checkboxes else I want to skip the macro. If chkbx1 is TRUE, I want to skip the macro. If chkbx2 is TRUE, I want to skip to skip the macro. If chkbx1 and chkbx2 are both TRUE, I want to skip the macro. This is what I have and it is not working (E6 and E7 are the cells linked to the checkbox controls.... Sub test() Worksheets("Data").Select Range("E6").Select If E6 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select ElseIf E7 = "TRUE" Then Worksheets("Form").Select Range("A4:I4").Select Else mcrSaveAs End If End Sub Thanks for any advice you may have! . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
calling macro in a formula | Excel Discussion (Misc queries) | |||
calling a dll from excel macro | Excel Programming | |||
calling a macro from within a loop | Excel Programming | |||
calling a macro from within a loop | Excel Programming | |||
Calling macro in add-in. | Excel Programming |