JohnZ1156
Board Regular
- Joined
- Apr 10, 2021
- Messages
- 152
- Office Version
- 2021
- Platform
- Windows
I have a range of cells which contain numbers, text and dates. Using VBA, I have "copied" the range. Now I make my target cell the active cell and want to paste the values with the formatting to this different sheet. It is pasting the values but not duplicating the text formatting or alignment formats (centered).
I wouild like the macro to copy the text font, date formats, number formats and alignment formats (centered).
Here's my code:
I wouild like the macro to copy the text font, date formats, number formats and alignment formats (centered).
Here's my code:
VBA Code:
Sub testone()
Worksheets("Invoice").Activate
Range("D20").Select
NumRows = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row - ActiveCell.Row + 1
' MsgBox (NumRows)
Range("P20:W" & NumRows + 19).Select
Selection.Copy
Sheets("Invoice List").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Sub