Hi All,
Been a while since I had to ask for help but HELP! I am trying to find the first blank row in a named TABLE. My code works for everything except the last WITH statement which is checking the last table. If you notice, all of the WITH statements are the same except for changing the table objects and the row identifiers. What is frustrating me is that the compile error is only being thrown for the last WITH statement against the variable lRowMgmtComment. I have already tried not using the SET statement for the variables but that throws a different error into the mix. If y'all can take a look and let me know why the first three WITH statements work fine but the last errors out, I would appreciate it.
Option Explicit
'THIS IS THE ONE
Sub NewerLastRow()
Dim Axis1, PICS1, Axis_Comments, Mgmt_Comments As ListObject
Dim sFileName As String 'show the open dialog and pass the selected file name to the string variable "sFileName"
Dim WB, wkbk As Workbook
Dim wkshtData, wkshtComment As Worksheet
Dim lRowAxisData, lRowAxisComment, lRowMgmtData, lRowMgmtComment As Long
Set wkbk = Workbooks("OB Analysis.xlsm")
Set wkshtData = Worksheets("Survey_Import_Data")
Set wkshtComment = Worksheets("Survey_Import_Comments")
Set Axis1 = wkshtData.ListObjects("Axis1")
Set PICS1 = wkshtData.ListObjects("PICS1")
Set Axis_Comments = wkshtComment.ListObjects("Axis_Comments")
Set Mgmt_Comments = wkshtComment.ListObjects("Mgmt_Comments")
With Axis1.Range.Columns(1)
Set lRowAxisData = .Find(what:="", after:=.Cells(1), LookIn:=xlValues, _
searchorder:=xlByRows, searchdirection:=xlNext) 'finds the first empty row in the table
If Not lRowAxisData Is Nothing Then
'do stuff`
Debug.Print "first empty row in Axis data is " & lRowAxisData.Row 'First empty row
End If
End With
With PICS1.Range.Columns(1)
Set lRowMgmtData = .Find(what:="", after:=.Cells(1), LookIn:=xlValues, _
searchorder:=xlByRows, searchdirection:=xlNext) 'finds the first empty row in the table
If Not lRowMgmtData Is Nothing Then
'do stuff`
Debug.Print "first empty row in Mgmt data is " & lRowMgmtData.Row 'First empty row
End If
End With
With Axis_Comments.Range.Columns(1)
Set lRowAxisComment = .Find(what:="", after:=.Cells(1), LookIn:=xlValues, _
searchorder:=xlByRows, searchdirection:=xlNext) 'finds the first empty row in the table
If Not lRowAxisComment Is Nothing Then
'do stuff`
Debug.Print "first empty row in Axis comments is " & lRowAxisComment.Row 'First empty row
End If
End With
With Mgmt_Comments.Range.Columns(1)
Set lRowMgmtComment = .Find(what:="", after:=.Cells(1), LookIn:=xlValues, _
searchorder:=xlByRows, searchdirection:=xlNext) 'finds the first empty row in the table
If Not lRowMgmtComment Is Nothing Then
'do stuff`
Debug.Print "first empty row in Mgmt comments is " & lRowMgmtComment.Row 'First empty row
End If
End With
End Sub
lRowMgmtComment.jpg