I'm getting syntax error when trying to create simple table and i don't know why. It works when i write .name after it and it also works when i write only ws.ListObjects.Add. So can somebody please explain what is the correct syntax?
Thank you.
Sub CreateTable()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Set wb = Workbooks("?????")
Set ws = wb.Worksheets("owssvr-úpravené")
Set rng = ws.Range("A1").CurrentRegion
rng.Find(What:="Next_Review_Date", LookAt:=xlWhole).Name = "Next_Review_Date"
With ws.Range("Next_Review_Date").Offset(0, 1)
.EntireColumn.Insert shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.EntireColumn.Insert shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.EntireColumn.Insert shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
End With
With ws.Range("Next_Review_Date")
.Offset(0, 1).Value = "Rozdiel dátumov"
.Offset(0, 2).Value = "Overdue"
.Offset(0, 3).Value = "Review year"
End With
ws.ListObjects.Add(xlSrcRange, rng, , xlYes)
End Sub
what is the correct syntax?...so that's what I posted a link to.wthat is the correct syntaxbecause VBA was marking it red like it was syntax problem so i thought i was wrting it in bad syntax. I visited that site but the brackets were the problem. I'm novice in VBA and sorry if you were annoyed with my question.