Hi!
I 'wrote' a macro using key strokes. I created a table which is done via the code below:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$M$75"), , xlYes).Name = _
"Table1"
My issue is I don't want the Range to always be the Range as defined here.
I will be using worksheets that will ALWAYS start at A1, but I have no idea how long or wide they will be.
I need something to allow the range to be variable based on where the data are.
I've seen a lot of code with:
lcol = ws.Cells(Rowno, 1).End(xlToRight).Column
lrow = ws.Cells(Rows.Count, Colno).End(xlUp).Row
Start = Cells(Rowno, Colno).Address
wb.Names.Add Name:="lcol", _
RefersTo:="=COUNTA($" & Rowno & ":$" & Rowno & ")"
wb.Names.Add Name:="lrow", _
RefersToR1C1:="=COUNTA(C" & Colno & ")"
wb.Names.Add Name:="myData", RefersTo:= _
"=" & Start & ":INDEX($1:$65536," & "lrow," & "Lcol)"
But can't seem to make that work. I'm relatively new to VBA coding, so I'm having some difficulty debugging.
Any help (along with what is happening in the code) is greatly appreciated!
I 'wrote' a macro using key strokes. I created a table which is done via the code below:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$M$75"), , xlYes).Name = _
"Table1"
My issue is I don't want the Range to always be the Range as defined here.
I will be using worksheets that will ALWAYS start at A1, but I have no idea how long or wide they will be.
I need something to allow the range to be variable based on where the data are.
I've seen a lot of code with:
lcol = ws.Cells(Rowno, 1).End(xlToRight).Column
lrow = ws.Cells(Rows.Count, Colno).End(xlUp).Row
Start = Cells(Rowno, Colno).Address
wb.Names.Add Name:="lcol", _
RefersTo:="=COUNTA($" & Rowno & ":$" & Rowno & ")"
wb.Names.Add Name:="lrow", _
RefersToR1C1:="=COUNTA(C" & Colno & ")"
wb.Names.Add Name:="myData", RefersTo:= _
"=" & Start & ":INDEX($1:$65536," & "lrow," & "Lcol)"
But can't seem to make that work. I'm relatively new to VBA coding, so I'm having some difficulty debugging.
Any help (along with what is happening in the code) is greatly appreciated!