Copy, PAste Special, Format only HELP

chefdt

Board Regular
Joined
Jul 1, 2008
Messages
163
I'm a bit brain dead tonight and cant make this work.

Simply trying to copy the formatting of the range from N4:N5 to the entire columns of O and T, both starting in row 4.

Row length will be variable from sheet to sheet. Here is what I have.

Code:
Sub reformatStripes()'
' reformatStripes Macro
'
Dim lastrow As Long
    lastrow = Range("A" & Rows.Count).End(xlUp).Row
'
    Selection.Copy
    Range("N4").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("O4:O" & lastrow).Select.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Range("T4:T" & lastrow).Select.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select
    
    

End Sub

 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try

Code:
Range("N4").Copy
Range("O4:O" & lastrow).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
Range("T4:T" & lastrow).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
 
Upvote 0
Works fine for me.
Granted it's only copying N4 (that's what your posted code copied), but your description said you wanted N4:N5.

So perhaps you wanted
Rich (BB code):
Range("N4:N5").Copy
Range("O4:O" & lastrow).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
Range("T4:T" & lastrow).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
 
Upvote 0
Bingo that was it. It's one of those "old school" reports that has every other row shaded. When I performed the calculations, i lost the formatting.

Thanks a ton.

DT
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top