PC Review


Reply
Thread Tools Rate Thread

Cell = "YES" then CommandButton2 Visible

 
 
cru
Guest
Posts: n/a
 
      14th Nov 2008
Any assistance is appreciated!

I need a code which will make the commandbutton2 visible if cell "d18" is YES.

Any ideas?

 
Reply With Quote
 
 
 
 
Kevin B
Guest
Posts: n/a
 
      14th Nov 2008
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?
>

 
Reply With Quote
 
cru
Guest
Posts: n/a
 
      14th Nov 2008
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?
> >

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      14th Nov 2008
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?
>

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      14th Nov 2008
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?
> > >

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      14th Nov 2008
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" <(E-Mail Removed)> wrote in message
news:7AD7A303-DD87-4A38-8BC8-(E-Mail Removed)...
> Any assistance is appreciated!
>
> I need a code which will make the commandbutton2 visible if cell "d18" is
> YES.
>
> Any ideas?
>


 
Reply With Quote
 
cru
Guest
Posts: n/a
 
      14th Nov 2008
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?
> >

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      14th Nov 2008
Just add this line to your macro...

CommandButton2.Visible = (Range("D18").Value = "YES"

--
Rick (MVP - Excel)


"cru" <(E-Mail Removed)> wrote in message
news:27331B24-76C7-4E4B-B16B-(E-Mail Removed)...
>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?
>> >


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      14th Nov 2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:7AD7A303-DD87-4A38-8BC8-(E-Mail Removed)...
>> Any assistance is appreciated!
>>
>> I need a code which will make the commandbutton2 visible if cell "d18" is
>> YES.
>>
>> Any ideas?
>>

>


 
Reply With Quote
 
cru
Guest
Posts: n/a
 
      14th Nov 2008
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >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" <(E-Mail Removed)> wrote in message
> > news:7AD7A303-DD87-4A38-8BC8-(E-Mail Removed)...
> >> Any assistance is appreciated!
> >>
> >> I need a code which will make the commandbutton2 visible if cell "d18" is
> >> YES.
> >>
> >> Any ideas?
> >>

> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding content of cell in visible "protected" sheets RiverGully Microsoft Excel Programming 4 5th Oct 2009 10:01 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Microsoft Excel Misc 2 8th Aug 2008 01:54 AM
"\\192.168.1.23\myshare" visible - "\\comp7" NOT visible - Why / How to list accesible computers ? Tom Hawkins Windows XP Help 1 29th Mar 2007 06:28 PM
"\\192.168.1.23\myshare" visible - "\\comp7" NOT visible - Why / How to list accesible computers ? Tom Hawkins Windows XP Networking 2 29th Mar 2007 06:28 PM
VBA to address first visible cell in Column "D" after filtering EagleOne Microsoft Excel Misc 2 11th Dec 2006 05:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:00 AM.