Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Hide button based on a cell value

Hello,

I have been trying to write a macro that would hide a button based on a cell
value (cell N20). Somehow, it doesn't work. If N20=1, the button should be
visible. If not, then it should be hidden.

The button is called Button 4388 and the sheet is called Results.

This is what I have come up with so far but as I said it doesn't work
(please don't laught, I'm a beginner!):

Sub HideButton()

Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
If Range("N20").Value = "1" Then
..Visible = True
Else
..Visible = False
End If
End With

End Sub


--
Johanna
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default Hide button based on a cell value

It depends on what type of "Button" you mean?

Try;

Sub HideButton()

Dim myButton As Shape

With ActiveSheet
Set myButton = .Shape("Button 4388")
myButton.Visible = .Range("N20") = 1
End With

End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Johanna Gronlund" wrote in
message ...
Hello,

I have been trying to write a macro that would hide a button based on a
cell
value (cell N20). Somehow, it doesn't work. If N20=1, the button should be
visible. If not, then it should be hidden.

The button is called Button 4388 and the sheet is called Results.

This is what I have come up with so far but as I said it doesn't work
(please don't laught, I'm a beginner!):

Sub HideButton()

Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
If Range("N20").Value = "1" Then
.Visible = True
Else
.Visible = False
End If
End With

End Sub


--
Johanna


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Hide button based on a cell value

Thanks for a quick reply.

It's a button from the form's control menu.

I tried the code but there is an error message which it highlights this row:
Set myButton = .Shape("Button 4388")

The error message is:
Run-time error '438'
Object doesn't support this property or method.

Johanna

--
Johanna G


"ozgrid.com" wrote:

It depends on what type of "Button" you mean?

Try;

Sub HideButton()

Dim myButton As Shape

With ActiveSheet
Set myButton = .Shape("Button 4388")
myButton.Visible = .Range("N20") = 1
End With

End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Johanna Gronlund" wrote in
message ...
Hello,

I have been trying to write a macro that would hide a button based on a
cell
value (cell N20). Somehow, it doesn't work. If N20=1, the button should be
visible. If not, then it should be hidden.

The button is called Button 4388 and the sheet is called Results.

This is what I have come up with so far but as I said it doesn't work
(please don't laught, I'm a beginner!):

Sub HideButton()

Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
If Range("N20").Value = "1" Then
.Visible = True
Else
.Visible = False
End If
End With

End Sub


--
Johanna


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Hide button based on a cell value

Try this

Sub HideButton()
Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
myButton.Visible = .Range("N20").Value = 1
End With

End Sub



--

HTH

Bob

"Johanna Gronlund" wrote in
message ...
Thanks for a quick reply.

It's a button from the form's control menu.

I tried the code but there is an error message which it highlights this
row:
Set myButton = .Shape("Button 4388")

The error message is:
Run-time error '438'
Object doesn't support this property or method.

Johanna

--
Johanna G


"ozgrid.com" wrote:

It depends on what type of "Button" you mean?

Try;

Sub HideButton()

Dim myButton As Shape

With ActiveSheet
Set myButton = .Shape("Button 4388")
myButton.Visible = .Range("N20") = 1
End With

End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Johanna Gronlund" wrote in
message ...
Hello,

I have been trying to write a macro that would hide a button based on a
cell
value (cell N20). Somehow, it doesn't work. If N20=1, the button should
be
visible. If not, then it should be hidden.

The button is called Button 4388 and the sheet is called Results.

This is what I have come up with so far but as I said it doesn't work
(please don't laught, I'm a beginner!):

Sub HideButton()

Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
If Range("N20").Value = "1" Then
.Visible = True
Else
.Visible = False
End If
End With

End Sub


--
Johanna




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Hide button based on a cell value

Thanks very much, that worked!!!

--
Johanna


"Bob Phillips" wrote:

Try this

Sub HideButton()
Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
myButton.Visible = .Range("N20").Value = 1
End With

End Sub



--

HTH

Bob

"Johanna Gronlund" wrote in
message ...
Thanks for a quick reply.

It's a button from the form's control menu.

I tried the code but there is an error message which it highlights this
row:
Set myButton = .Shape("Button 4388")

The error message is:
Run-time error '438'
Object doesn't support this property or method.

Johanna

--
Johanna G


"ozgrid.com" wrote:

It depends on what type of "Button" you mean?

Try;

Sub HideButton()

Dim myButton As Shape

With ActiveSheet
Set myButton = .Shape("Button 4388")
myButton.Visible = .Range("N20") = 1
End With

End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Johanna Gronlund" wrote in
message ...
Hello,

I have been trying to write a macro that would hide a button based on a
cell
value (cell N20). Somehow, it doesn't work. If N20=1, the button should
be
visible. If not, then it should be hidden.

The button is called Button 4388 and the sheet is called Results.

This is what I have come up with so far but as I said it doesn't work
(please don't laught, I'm a beginner!):

Sub HideButton()

Dim myButton As Button

With ActiveSheet
Set myButton = .Buttons("Button 4388")
If Range("N20").Value = "1" Then
.Visible = True
Else
.Visible = False
End If
End With

End Sub


--
Johanna



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/unhide a button based on selection in a combobox Johanna Gronlund Excel Programming 2 April 1st 10 08:29 AM
Hide Next row based on Cell Value VS182501 Excel Programming 3 May 20th 09 10:22 AM
How do I hide a command button based on a condition? [email protected] Excel Programming 4 May 3rd 06 02:47 PM
Is there a way to HIDE a row based on a value of a cell ? Reddiance Excel Discussion (Misc queries) 4 January 26th 05 02:57 AM
Hide Row Based on cell value GaryF Excel Programming 3 April 27th 04 04:55 PM


All times are GMT +1. The time now is 06:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"