Hi Guys,
Been trying to figure this out using ListObjects.Add, but so far no luck. Here's the scenario...
Let's say VBA code dynamically produces an unknown number of column headers on a separate worksheet. I want to declare a table, and format it as such based on how many columns are produced.
So let's say it makes Col1, Col2, and Col3. Now, I have a function that tells me how many columns there are, and I can convert the number of columns into the actual alpha characters that represent the column. So my code will actually tell me that Col3 lies in column 'C' in excel before declaring my table name.
Either a Loop that determines the first empty cell in column A or declaring the range based on what I already know (A1:C1) should work. I just don't know how to make the range dynamic so it accepts my range inputs properly. If it's a static cell reference it's no problem. I've used this...but I'm not sure how to change the "A1:C1" in Range to a dynamic value?:
Sheet1.ListObjects.Add(xlSrcRange, Range("A1:C1"), , xlYes).Name = "myTable1"
Been trying to figure this out using ListObjects.Add, but so far no luck. Here's the scenario...
Let's say VBA code dynamically produces an unknown number of column headers on a separate worksheet. I want to declare a table, and format it as such based on how many columns are produced.
So let's say it makes Col1, Col2, and Col3. Now, I have a function that tells me how many columns there are, and I can convert the number of columns into the actual alpha characters that represent the column. So my code will actually tell me that Col3 lies in column 'C' in excel before declaring my table name.
Either a Loop that determines the first empty cell in column A or declaring the range based on what I already know (A1:C1) should work. I just don't know how to make the range dynamic so it accepts my range inputs properly. If it's a static cell reference it's no problem. I've used this...but I'm not sure how to change the "A1:C1" in Range to a dynamic value?:
Sheet1.ListObjects.Add(xlSrcRange, Range("A1:C1"), , xlYes).Name = "myTable1"