Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
I have a table (Range B11 - L250). I would like to change this code to do the following...
1. If I select a cell outside B11 - L250, i would like the textbox to display "New Expense"
2. If i select any cell inside B11 - L250 that has data, I would like the textbox to display "Edit Expense".
3. If i select any cell inside B11 - L250 that does NOT have data, I would like the textbox to display "Edit Expense".
Could someone help, please.
Thank you for your help.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Range
Set r = Application.Intersect(Target, Range("B11:B250"))
If r Is Nothing Then Exit Sub
If r.Cells.Count <> 1 Then Exit Sub
With ActiveWorkbook.ActiveSheet.Shapes("Register")
If r.Value2 = Empty Then
.TextFrame.Characters.Text = "New Expense"
.TextFrame.Characters(1, 11).Font.Color = 16777215 'white
.Fill.ForeColor.RGB = RGB(0, 0, 255) 'blue
Else
.TextFrame.Characters.Text = "Edit Expense"
.TextFrame.Characters(1, 12).Font.Color = 0 'Black
.Fill.ForeColor.RGB = RGB(255, 0, 0) 'red
End If
End With
End Sub
1. If I select a cell outside B11 - L250, i would like the textbox to display "New Expense"
2. If i select any cell inside B11 - L250 that has data, I would like the textbox to display "Edit Expense".
3. If i select any cell inside B11 - L250 that does NOT have data, I would like the textbox to display "Edit Expense".
Could someone help, please.
Thank you for your help.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Range
Set r = Application.Intersect(Target, Range("B11:B250"))
If r Is Nothing Then Exit Sub
If r.Cells.Count <> 1 Then Exit Sub
With ActiveWorkbook.ActiveSheet.Shapes("Register")
If r.Value2 = Empty Then
.TextFrame.Characters.Text = "New Expense"
.TextFrame.Characters(1, 11).Font.Color = 16777215 'white
.Fill.ForeColor.RGB = RGB(0, 0, 255) 'blue
Else
.TextFrame.Characters.Text = "Edit Expense"
.TextFrame.Characters(1, 12).Font.Color = 0 'Black
.Fill.ForeColor.RGB = RGB(255, 0, 0) 'red
End If
End With
End Sub