Eric Carolus
Board Regular
- Joined
- Sep 17, 2012
- Messages
- 128
- Office Version
- 2016
- Platform
- Windows
Hi folks
The code below allows me to get the cell address, the row number and the value of the last non-empty cell
in column C of worksheet called Teachers.
I can select (LastCell.Select), but I cannot change the the cell fill
with LasCell.Interior.Color = vbYellow.
I have scanned the literature but cannot find suitable information.
I know that the cell's address (given by LastCell.Address) is a string, but I simply fail
to change the cells fill.
I can use all help I can get. Thanks in advance.
Private Sub cmdOneTeach_Click() [A button]
Dim WS As Worksheet
Dim LastCell As Range
Dim LastCellRowNumber As Long
Dim myrange As Range
Set WS = Worksheets("Teachers")
With WS
Set LastCell = .Cells(.Rows.Count, "C").End(xlUp)
' ActiveCell = LastCell.Select
'''''''' ActiveCell.Offset(0, 1).Interior.Color = vbYellow
LastCellRowNumber = LastCell.Row
LastCell.Select
End With
MsgBox "JW:PP is cell content: " & LastCell _
& vbCrLf _
& vbCrLf _
& "Number is " & LastCellRowNumber _
& vbCrLf _
& vbCrLf _
& "The cell address is: " & LastCell.Address
Eric
The code below allows me to get the cell address, the row number and the value of the last non-empty cell
in column C of worksheet called Teachers.
I can select (LastCell.Select), but I cannot change the the cell fill
with LasCell.Interior.Color = vbYellow.
I have scanned the literature but cannot find suitable information.
I know that the cell's address (given by LastCell.Address) is a string, but I simply fail
to change the cells fill.
I can use all help I can get. Thanks in advance.
Private Sub cmdOneTeach_Click() [A button]
Dim WS As Worksheet
Dim LastCell As Range
Dim LastCellRowNumber As Long
Dim myrange As Range
Set WS = Worksheets("Teachers")
With WS
Set LastCell = .Cells(.Rows.Count, "C").End(xlUp)
' ActiveCell = LastCell.Select
'''''''' ActiveCell.Offset(0, 1).Interior.Color = vbYellow
LastCellRowNumber = LastCell.Row
LastCell.Select
End With
MsgBox "JW:PP is cell content: " & LastCell _
& vbCrLf _
& vbCrLf _
& "Number is " & LastCellRowNumber _
& vbCrLf _
& vbCrLf _
& "The cell address is: " & LastCell.Address
Eric