dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,392
- Office Version
- 365
- 2016
- Platform
- Windows
I have some code, trying to format several columns as dates, what is wrong with it as it won't work?
Code:
Set sht = Worksheets("Home")
With sht
Set tbl = .ListObjects("tblCosting")
For Each tblrow In tbl.ListRows
Combo = Format(tblrow.Range.Cells(1, 1), "mmmm yyyy")
Set wsDst = Sheets(Combo)
With wsDst
'This copies the first 10 columns, i.e. A:J, of the current row of the table to column A in the destination sheet.
tblrow.Range.Resize(, 10).copy
With .Range("A" & Rows.Count).End(xlUp).Offset(1)
.PasteSpecial xlPasteValuesAndNumberFormats
[COLOR=#ff0000] .Columns("A", "AD", "AE").NumberFormat = "dd/mm/yyyy"[/COLOR]
'This should go to the 15th column in the current row, i.e. column O, and copy that column and the next 2 columns, i.e. O:Q, to column K on the destination sheet.
tblrow.Range.Offset(, 14).Resize(, 3).copy
.Range("K" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
'Similarly this should copy columns AD:AF from the table to column N on the destination sheet.
tblrow.Range.Offset(, 29).Resize(, 3).copy
.Range("N" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
End With
Next tblrow