AndreB
09-14-2021, 09:50 AM
Dear Gurus,
adding a column to a table, I'd like to set the number format of the data in advance - numbers with two decimal digits or accounting.
Here below the code I'm using and in which I'd like to add a statement that selects the cells of the column changing their format.
Set ws2 = Worksheets("Resources")
Set table2 = ws2.ListObjects("Table2")
With table2
For i = 1 To durY
.ListColumns.Add
colCount = .ListColumns.Count
.HeaderRowRange(colCount).NumberFormat = "yyyy"
.HeaderRowRange(colCount).Value = DateAdd("yyyy", i - 1, stdate)
Next i
End With
I've tried adding, before the next, the statement:
.ListColumns(colCount2).DataBodyRange.NumberFormat = "Accounting"
But this is giving me an Application-defined error.
Could you please let me know where/ what I'm making wrong?
Thanks in advance,
A.
adding a column to a table, I'd like to set the number format of the data in advance - numbers with two decimal digits or accounting.
Here below the code I'm using and in which I'd like to add a statement that selects the cells of the column changing their format.
Set ws2 = Worksheets("Resources")
Set table2 = ws2.ListObjects("Table2")
With table2
For i = 1 To durY
.ListColumns.Add
colCount = .ListColumns.Count
.HeaderRowRange(colCount).NumberFormat = "yyyy"
.HeaderRowRange(colCount).Value = DateAdd("yyyy", i - 1, stdate)
Next i
End With
I've tried adding, before the next, the statement:
.ListColumns(colCount2).DataBodyRange.NumberFormat = "Accounting"
But this is giving me an Application-defined error.
Could you please let me know where/ what I'm making wrong?
Thanks in advance,
A.