VBA to paste special not working

grapevine

Board Regular
Joined
May 23, 2007
Messages
208
I have a piece of vba code which is copying and pasting to another sheet. the copy and paste is working as I have tested to make sure by overtyping the formula with text to check.

If ActiveCell.Value <> "" Then
ActiveCell.Offset(1, -4).Copy Destination:=Workbooks(FSN & "." & "HDR").Worksheets(2).Range("b11")

My problem is I cannot get this to do a paste special. I have tried adding the two alternatives below to the end of the script based on advice that I have found on the Internet but I keep getting the following error: compile error expected end of statement

Range("b11").PasteSpecial Paste:=xlPasteValues
Range("b11").PasteSpecial PasteValues

Can anyone help me out please?
Kind regards
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Remove Destination:=, move the code after that to a new line and add .PasteSpecial xlPasteValues.

Code:
ActiveCell.Offset(1, -4).Copy

Workbooks(FSN & "." & "HDR").Worksheets(2).Range("B11").PasteSpecial xlPasteValues
 
Upvote 0
Thank you for your very quick reply, but I am now getting a different error

Runtime Error 1004 Pastespecial Method of Range Class Failed

Any clues???

Kind regards
 
Upvote 0
Alert over - I think I caused a glitch as I was running and adapting the code in break mode. I closed everything down - re ran the macro and all it working perfectly.

Thank you very much - a very simple solution.
Kind regards
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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