neilm4247
04-20-2016, 12:45 PM
I am having difficulty assigning a variable to a table or a table name. If I use the code as shown I get an "object required" error on the line in bold. Is a ListObject not an object? If I use tblName instead I get an "Invalid qualifier" error.
Sub TestFillTemplateCopy()
Dim TDate As String
Dim tbl As ListObject
Dim tblName As String
Dim rn As Integer ' row number
TDate = Date
Set tbl = Sheets("Flexpak").ListObjects(1)
tblName = Sheets("Flexpak").ListObjects(1).Name
rn = 2
'While Not IsEmpty(Sheets("Flexpak").Range(Cells(rn, 1))
Sheets("TemplateSheet").Copy Before:=Sheets(4)
With ActiveSheet
.Range("C1").Value = Date
.Range("B14").Value = [tbl].Cells(rn, [tbl[Part.]].Column)
End With
'Wend
End Sub
Any help is appreciated.
Sub TestFillTemplateCopy()
Dim TDate As String
Dim tbl As ListObject
Dim tblName As String
Dim rn As Integer ' row number
TDate = Date
Set tbl = Sheets("Flexpak").ListObjects(1)
tblName = Sheets("Flexpak").ListObjects(1).Name
rn = 2
'While Not IsEmpty(Sheets("Flexpak").Range(Cells(rn, 1))
Sheets("TemplateSheet").Copy Before:=Sheets(4)
With ActiveSheet
.Range("C1").Value = Date
.Range("B14").Value = [tbl].Cells(rn, [tbl[Part.]].Column)
End With
'Wend
End Sub
Any help is appreciated.