PDA

View Full Version : Solved: Cmd Button Caption



av8tordude
04-25-2009, 09:47 PM
I have a cmd button on a worksheet. In column A, I will be entering dates. If I select a cell that has a date, how do I get the cmd button caption to change from New to Edit?

MaximS
04-25-2009, 10:19 PM
try that:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Intersect(Target, Me.Range("A1:A" & Rows.Count)) Is Nothing Then Exit Sub
If IsDate(Target) Then
CommandButton1.Caption = "Edit"
Else
CommandButton1.Caption = "New"
End If
End Sub

av8tordude
04-25-2009, 10:43 PM
Hi Maxim,

Thank you for responding. The code works great, Thank you. One more question if I may ask...I'm using a useform to enter data. Once I enter the data into the worksheet via the userform, How do I get the active cell to move down to the next cell?

av8tordude
04-25-2009, 11:00 PM
I found what I was looking for in the search engine. Thank you :beerchug:

ActiveCell.Offset(1, 0).Select

MaximS
04-25-2009, 11:05 PM
try that:


Private Sub CommandButton1_Click()
Worksheets("Sheet1").Activate
Selection.Offset(1, 0).Select
End Sub