Look at this code. Can I make it copy only formatting?

Sven62

Active Member
Joined
Feb 21, 2012
Messages
485
Range(Cells(iVar, 1), Cells(iVar, 12)).Resize(2).FillDown
Range(Cells(iVar, 14), Cells(iVar, 38)).Resize(2).FillDown

Can it be...?

Range(Cells(iVar, 1), Cells(iVar, 12)).Resize(2).FillDown.Format
Range(Cells(iVar, 14), Cells(iVar, 38)).Resize(2).FillDown.Format

Is there any way to filldown only the formatting? I am trying to make it copy only the formatting from those cells in the last used line to the cells in the next line down.

More of the code reads thusly...

Code:
Private Sub CommandButton2_Click()
Dim ws As Worksheet
Dim rngNext As Range
Dim iVar As Long

      iVar = Range("B" & Rows.Count).End(xlUp).Row
      Set ws = Worksheets("EVENTS") 
 
      Set rngNext = ws.Range("B" & Rows.Count).End(xlUp).Offset(1)
      
      Range(Cells(iVar, 1), Cells(iVar, 12)).Resize(2).FillDown
      Range(Cells(iVar, 14), Cells(iVar, 38)).Resize(2).FillDown
      
   
       rngNext.Value = Calendar.Value
       
       rngNext.Offset(, 1).Value = MOR.Value
       
       rngNext.Offset(, 2).Value = LOSS.Value
       
       rngNext.Offset(, 3).Value = OD.Value

 Unload Me
              
End Sub
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Copy, and then PasteSpecial.

Code:
    With ws.Cells(iVar, 1)
        .Resize(, 12).Copy
        .Offset(1).PasteSpecial xlPasteFormats
        With .Offset(, 13).Resize(, 25)
            .Copy
            .Offset(1).PasteSpecial xlPasteFormats
        End With
    End With
 
Upvote 0
Hi Sven. Try:
Code:
Range(Cells(iVar, 1), Cells(iVar, 12)).Copy
    Cells(iVar, 1).Offset(1, 0).PasteSpecial (xlPasteFormats)
    Range(Cells(iVar, 14), Cells(iVar, 38)).Copy
    Cells(iVar, 14).Offset(1, 0).PasteSpecial (xlPasteFormats)
    Application.CutCopyMode = False
 
Upvote 0

Forum statistics

Threads
1,203,067
Messages
6,053,335
Members
444,654
Latest member
Rich Cohen

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