In this video you will see:
- One Method of Finding the Final Row on a Sheet
- One Method of Finding the Final Column on a Sheet
- Creation of a Class Module
Private Function pFinalRow() As Long
'This Function is dependant on data being present in column A (an longer or equal in length that other columns)
pFinalRow = Cells(Application.Rows.Count, 1).End(xlUp).Row
End Function
Private Function piFinalCol() As Long
'This Function is dependant on FinalRow returning the correct value.
Dim rInt As Long
rInt = ActiveSheet.UsedRange.Count
piFinalCol = rInt / FinalRow
End Function
Private Function psFinalCol() As String
'This Function is dependant on FinalRow returning the correct value.
Dim rInt As Long
rInt = ActiveSheet.UsedRange.Count
psFinalCol = Chr((rInt / FinalRow) + 64)
End Function
Public Property Get FinalRow()
FinalRow = pFinalRow
End Property
Public Property Get iFinalCol()
iFinalCol = piFinalCol
End Property
Public Property Get sFinalCol()
sFinalCol = psFinalCol
End Property
psFinalCol = Chr((rInt / FinalRow) + 64) didnt work for me. I am using Excel2010
ReplyDeleteYou are correct, you will need a more in depth class file.
ReplyDeleteI recently started work on one designed for a the final column. I have posted what I have done so far, it's not much.: http://vb4excel.blogspot.com/2013/03/excel-vba-class-module-final-column.html
Better Class files can be found here: (There are designed for the Final Row)
http://vb4excel.blogspot.com/2012/01/excel-vba-find-final-row-class-module.html
Tutorial on how to make your own class file:
http://www.youtube.com/watch?v=LD015-J9Qnw