PasteSPecial Formulas and Formates

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
Knowing that if I wanted to Paste Formulas and Formats that it’s the equivalent to a simple paste, but that doesn’t see to work if I try to modify what I am doing with this code.

I changed to .Cells(101, e).Paste but it doesn’t like this part of the code.

How do I change the following to paste all? Or do I need to run through this and Pasteformat and then PasteFormulas?

Dim e As Long
Dim LastCol As Long

With Sheets("Cash Flow")
LastCol = .Cells(1, .Columns.Count).End(xlUp).Column
End With

With Sheets("Cash Flow")
.Range("D101:D106").Copy
For e = 5 To LastCol
If Len(.Cells(6, e).Value) <> 0 Then
.Cells(101, e).PasteSpecial Paste:=xlPasteFormulas
End If
Next e
End With
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
The Range object doesn't have a Paste method. You could use xlPasteAll as the Paste argument for the PasteSpecial method. Or you could use the Destination argument of the Copy method.
 
Upvote 0
Does this really work?:
LastCol = .Cells(1, .Columns.Count).End(xlUp).Column

I'd have expected xlToLeft

Code:
Sub blah()
Dim e As Long
Dim LastCol As Long

With Sheets("Cash Flow")
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    For e = 5 To LastCol
        If Len(.Cells(6, e).Value) <> 0 Then
            .Range("D101:D106").Copy .Cells(101, e).Resize(6)
        End If
    Next e
End With
End Sub

 
Last edited:
Upvote 0
Try

Code:
If Len(.Cells(6, e).Value) <> 0 Then
    .Cells(101, e).PasteSpecial Paste:=xlPasteFormulas
    .Cells(101, e).PasteSpecial Paste:=xlPasteFormats
End If
 
Upvote 0
Try this:

Code:
With Sheets("Cash Flow")
    .Range("D101:D106").Copy
    For e = 5 To LastCol
        If Len(.Cells(6, e).Value) <> 0 Then
            [COLOR=blue][B].Paste .Cells(101, e)[/B][/COLOR]
        End If
    Next e
End With

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

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