macro to copy data from sheet3to sheet4 using paste special values

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have the following code which I have written to copy data from sheet3 to Sheet 4 using paste special values


I get invalid qualified when running the macro

Code:
 PasteSpecial Paste:=xlPasteValues.Sheet(4).Range("A1")


It would be appreciated if someone could amend me code




Code:
 Sub Copy_raw_JNLDATa()
Dim lr As Long
  Sheets(4).UsedRange.ClearContents
  
  
 
  With Sheets(3)
  
    lr = .Range("A" & .Rows.Count).End(xlUp).Row
    .Range("A1:I" & lr).Copy
    PasteSpecial Paste:=xlPasteValues.Sheet(4).Range("A1")
      End With
  Sheets(4).UsedRange.EntireColumn.AutoFit
  
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try:

Code:
PasteSpecial Paste:=xlPasteValues.Sheet[COLOR=#ff0000]s[/COLOR](4).Range("A1")
 
Upvote 0
Thanks for I get "compile error-Invalid qualifier" when using code below


Code:
 PasteSpecial Paste:=xlPasteValues.Sheets(4).Range("A1")
 
Upvote 0
Hi Howard,

Just a little change around should do it:-


Code:
Sub Copy_raw_JNLDATa()
 
Dim lr As Long

Sheets(4).UsedRange.ClearContents
  
With Sheets(3)
      lr = .Range("A" & .Rows.Count).End(xlUp).Row
      .Range("A1:I" & lr).Copy
     [COLOR=#ff0000] Sheets(4).Range("A1")[/COLOR].PasteSpecial Paste:=xlPasteValues
End With
      
Sheets(4).UsedRange.Columns.AutoFit
  
End Sub

Cheerio,
vcoolio.
 
Last edited:
Upvote 0
You're welcome Howard.
Glad we could help.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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