PDA

View Full Version : A40 last cell



kubek
10-20-2008, 11:39 AM
Hello,

does anybody help me to modify this code to get the cells until A40, and not more?
I am new in VBA - thanks for your support.

With Worksheets(WorksheetName)
xlLastRow = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByRows, xlPrevious).Row
End With

Bob Phillips
10-20-2008, 11:56 AM
With Worksheets(WorksheetName)
xlLastRow = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByRows, xlPrevious).Row
If xlLastRow > 40 Then xlLastRow = 40
End With

kubek
10-21-2008, 10:11 AM
Ok thanks it seems to be ok for last row, but still my listbox shows the empty rows in the window, why? maybe i should modify the statement:

With Me.ListBox1
.BoundColumn = 1
.ColumnCount = 6
.ColumnHeads = True
.TextColumn = True
.ColumnWidths = "45;110;25;45;45"
.RowSource = "DATA!A2:H" & xlLastRow("DATA")
.ListStyle = fmListStyleOption
.ListIndex = 0
End With
??

But seems to be not right the last populated row formule, please help...