Guzzlr
Well-known Member
- Joined
- Apr 20, 2009
- Messages
- 982
- Office Version
- 2021
- Platform
- Windows
Hello
For Finding the last cell with data, I have:
The above is working correctly.
I now have the code that I am trying to incorporate LastCell into:
The above code I have used many times, but I've always used something like: Range ("5:5000")
I would like to be able to use the LastCell instead of a random number like Row 5000. However, I've never used the LastCell before to replace the row number.
How would I do that?
Thank you for the help
For Finding the last cell with data, I have:
VBA Code:
Dim LastCell as Range
Set LastCell = ActiveSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
MsgBox "The Last Cell with Data Is In Row: " & LastCell.Row
I now have the code that I am trying to incorporate LastCell into:
Code:
Set fnd = Range("5:5").Find("Service Provider", , , xlWhole, , , False, , False)
If Not fnd Is Nothing Then
Intersect(Range("5:LastCell"), fnd.EntireColumn).Copy
Range("O5").Insert Shift:=xlToRight
Intersect(Range("1:LastCell"), fnd.EntireColumn).Clear
Range("B:B").Delete
The above code I have used many times, but I've always used something like: Range ("5:5000")
I would like to be able to use the LastCell instead of a random number like Row 5000. However, I've never used the LastCell before to replace the row number.
How would I do that?
Thank you for the help