Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Any assistance is appreciated!
I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Press Alt + F11 to open the Visual Basic Editor. In the project window,
under MICROSOFT EXCEL OBJECTS double click the workseet that has the command buttons. In the worksheet module add the following event code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("D18").Value = "Yes" Then Me.CommandButton2.Visible = True Else Me.CommandButton2.Visible = False End If End Sub -- Kevin Backmann "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Kevin,
Thank you so much! Cru "Kevin B" wrote: Press Alt + F11 to open the Visual Basic Editor. In the project window, under MICROSOFT EXCEL OBJECTS double click the workseet that has the command buttons. In the worksheet module add the following event code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("D18").Value = "Yes" Then Me.CommandButton2.Visible = True Else Me.CommandButton2.Visible = False End If End Sub -- Kevin Backmann "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you will have better luck in the Worksheet Change Event
"cru" wrote: Hi Kevin, Thank you so much! Cru "Kevin B" wrote: Press Alt + F11 to open the Visual Basic Editor. In the project window, under MICROSOFT EXCEL OBJECTS double click the workseet that has the command buttons. In the worksheet module add the following event code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("D18").Value = "Yes" Then Me.CommandButton2.Visible = True Else Me.CommandButton2.Visible = False End If End Sub -- Kevin Backmann "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$18" Then If UCase(Target.Value) = "YES" Then CommandButton2.Visible = True else CommandButton2.Visible = false End If End If End Sub "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I originally used the following code use macro (excluding if condition):
Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub Is there a way to insert the code into the above code so that if "d18" = "yes" the button will be visible? Thanks, cru "Mike" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then If UCase(Target.Value) = "YES" Then CommandButton2.Visible = True else CommandButton2.Visible = false End If End If End Sub "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just add this line to your macro...
CommandButton2.Visible = (Range("D18").Value = "YES" -- Rick (MVP - Excel) "cru" wrote in message ... I originally used the following code use macro (excluding if condition): Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub Is there a way to insert the code into the above code so that if "d18" = "yes" the button will be visible? Thanks, cru "Mike" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then If UCase(Target.Value) = "YES" Then CommandButton2.Visible = True else CommandButton2.Visible = false End If End If End Sub "cru" wrote: Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A shorter routine...
Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I really should have filtered the change event. For the case-sensitive
version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (Target.Value = "YES") End If End Sub For the non-case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (UCase(Target.Value) = "YES") End If End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... A shorter routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick,
How can I incorporate the code you have to the following code: Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub I currently have this but if I can incorporate your code into the above code then I wanted to see if I can eliminate from creating commandbutton. Thanks. cru "Rick Rothstein" wrote: I really should have filtered the change event. For the case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (Target.Value = "YES") End If End Sub For the non-case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (UCase(Target.Value) = "YES") End If End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... A shorter routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just add this line to your macro...
CommandButton2.Visible = (Range("D18").Value = "YES") -- Rick (MVP - Excel) "cru" wrote in message ... Rick, How can I incorporate the code you have to the following code: Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub I currently have this but if I can incorporate your code into the above code then I wanted to see if I can eliminate from creating commandbutton. Thanks. cru "Rick Rothstein" wrote: I really should have filtered the change event. For the case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (Target.Value = "YES") End If End Sub For the non-case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (UCase(Target.Value) = "YES") End If End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... A shorter routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is it your trying to do with the commandbutton ? I have no clue....
"cru" wrote: Rick, How can I incorporate the code you have to the following code: Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub I currently have this but if I can incorporate your code into the above code then I wanted to see if I can eliminate from creating commandbutton. Thanks. cru "Rick Rothstein" wrote: I really should have filtered the change event. For the case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (Target.Value = "YES") End If End Sub For the non-case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (UCase(Target.Value) = "YES") End If End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... A shorter routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry Mike...
My goal is to have the command button to fire off the following sequence. 1. If D18 = Yes; 2. Button be visible for Print Preview 3. Upon pressing the button 2. Open hidden Ltr1 tab 3. Preview Ltr1 tab 4. If D18 = No; 3. Button be hidden I apologize for the vague question and I do appreciate your help. Thanks. cru "Mike" wrote: What is it your trying to do with the commandbutton ? I have no clue.... "cru" wrote: Rick, How can I incorporate the code you have to the following code: Sub Print_Preview_InputForm12() ' ' Print_Preview Macro ' Dim Answer As String Sheets("Ltr1").Visible = True Sheets("Ltr1").Select Range("A1:K48").Select ActiveSheet.PageSetup.PrintArea = Selection.Address ActiveSheet.PrintPreview Sheets("Print Ctr").Select End Sub I currently have this but if I can incorporate your code into the above code then I wanted to see if I can eliminate from creating commandbutton. Thanks. cru "Rick Rothstein" wrote: I really should have filtered the change event. For the case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (Target.Value = "YES") End If End Sub For the non-case-sensitive version... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$18" Then CommandButton1.Visible = (UCase(Target.Value) = "YES") End If End Sub -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... A shorter routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (Range("D18").Value = "YES") End Sub Note that the above is case-sensitive; here is a non-case-sensitive routine... Private Sub Worksheet_Change(ByVal Target As Range) CommandButton1.Visible = (UCase(Range("D18").Value) = "YES") End Sub -- Rick (MVP - Excel) "cru" wrote in message ... Any assistance is appreciated! I need a code which will make the commandbutton2 visible if cell "d18" is YES. Any ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Empty a cell if the values equal to "IN" , "MC" or "PP" | Excel Programming | |||
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! | Excel Discussion (Misc queries) | |||
VBA to address first visible cell in Column "D" after filtering | Excel Discussion (Misc queries) | |||
Complex if test program possible? If "value" "value", paste "value" in another cell? | Excel Discussion (Misc queries) |