ok so I have some data sent over to me in tables. I need to run some automated activities on these tables. I have found that my trusty old last row and last column functions are not reading the data in the tables.
Trusty Last column code
this returns a value of zero (0) when the data is in a table. I have no idea why. I can use the other simple last column code
this requires that the code can get the first row or first column of the databodyrange. This is where I am having issues.
I need to either amend the first code so that I can use old trusty with tables, or I need to understand how to get the first row's position on the worksheet (so if the table starts at A6, then the row of the first row is 6).
I'm a little lost here.
thanks,
Trusty Last column code
Code:
Public Function LASTCOL(ws As Worksheet)
Dim rngLCOL As Range
Dim lngCOLS As Long
ws.Select
With ws
Set rngLCOL = .Cells
On Error Resume Next
lngCOLS = rngLCOL.Find(What:="*", _
after:=rngLCOL.Cells(1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
End With
On Error GoTo 0
If Err > 0 Then
lngCOLS = 1
End If
LASTCOL = lngCOLS
End Function
this returns a value of zero (0) when the data is in a table. I have no idea why. I can use the other simple last column code
Code:
lastCOL=ws.cells(1,ws.columns.count).end(xltoleft).column
this requires that the code can get the first row or first column of the databodyrange. This is where I am having issues.
I need to either amend the first code so that I can use old trusty with tables, or I need to understand how to get the first row's position on the worksheet (so if the table starts at A6, then the row of the first row is 6).
I'm a little lost here.
thanks,