A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Command button depending on Cell Value



 
 
Thread Tools Display Modes
  #1  
Old January 14th 08, 11:11 AM posted to microsoft.public.excel.misc
Steve[_11_]
external usenet poster
 
Posts: 16
Default Command button depending on Cell Value

Hi

I'm trying to have a command button which works differently depending
on the value in a cell (V3). If the value is 2, I want the button text
to say 'Go to Part 5' and then go to sheet 5 when clicked, or if the
V3 value is 1, I want the button to say 'Go to Part 9' and go to
worksheet 9 when clicked.

Is this possible?

I'd also tried doing it as 2 buttons, one over the other, with the
second being invisible unless the value of V3 = 2.

Would this be easier, and if so, how would I do it?

I'd really be grateful for any advice.

Steve
Ads
  #2  
Old January 14th 08, 11:34 AM posted to microsoft.public.excel.misc
Carim[_2_]
external usenet poster
 
Posts: 97
Default Command button depending on Cell Value

Hi Steve,

You do need two event macros ...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$V$3" Then
With Target
If .Value = 1 Then
CommandButton1.Caption = "GO TO PART 5"
ElseIf .Value = 2 Then
CommandButton1.Caption = "GO TO PART 9"
End If
End With
End If
End Sub

Private Sub CommandButton1_Click()
If Range("V3").Value = 1 Then
Sheet5.Activate
ElseIf Range("V3").Value = 2 Then
Sheet9.Activate
End If
End Sub

HTH
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hide button depending on date Ed Davis Excel Worksheet Functions 1 May 1st 07 08:46 AM
Command button CEG Excel Discussion (Misc queries) 1 May 4th 06 09:54 PM
How do i clear a cell using a command button? Mariann Excel Discussion (Misc queries) 1 March 30th 06 09:15 PM
adding a command button to an excel cell? betelguese Excel Discussion (Misc queries) 1 March 22nd 05 03:09 AM
Command Button Chris Hale Excel Discussion (Misc queries) 1 February 10th 05 05:14 AM


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


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