• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to find out last cell in the column

Shailender

Member
Hello All, Here is the question, I have the data till AW column, in that there are many blank cells in the columns, how to select AW19 cell through vba. I have highlighted the AW19 cell with red color.

Please refer to the Sheet1.

Thank you in advance!
 

Attachments

  • Column.xlsx
    14.4 KB · Views: 4
In that case You maybe would like to get this:
Code:
aw_y_max = Sheets("Sheet1").UsedRange.Rows.Count
Use it like this :-
Code:
Sub AW()

aw_y_max = Sheets("Sheet1").UsedRange.Rows.Count

With Worksheets("Sheet1")
        .Cells.Item(aw_y_max, "AW").Interior.ColorIndex = 3
End With

End Sub
 
Thank you Derek & Vletm for the reply, Could you please let me know how to select the last cell which was used in the sheet..? In this case i want to select AW19. Please refer to the above attached sheet.
 
@vletm, thank you for the prompt response, Every month the column will get increased. So how to find out the last used column dynamically..?
 
Try using the code after you active the sheet:


Code:
Dim J as integer
J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).row
 
Try this to find fist row last column dynamically.

Code:
Sub Test()

Dim lastColumn As Integer
With ActiveSheet
lastColumn = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
MsgBox lastColumn
End Sub
 
Back
Top