Using PasteSpecial with Destination macro code and error

azmatb

New Member
Joined
Oct 20, 2022
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I have this code to copy data rows from worksheet Download from File1 to School Employee Info worksheet. Both worksheets are in one excel file.
When i run the code below, it copies fine, but in the School Employee Info file, the formatting is not correct. So i was trying to use PasteSpecial code below and it becomes in red color in VBA window. Not sure if this is right or not. Any help will be appreciated.

'Employee Status
Worksheets("Download from File1").Cells(i, 13).Copy
Worksheets("Download from File1").Paste Destination:=Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Change to this:
VBA Code:
Worksheets("Download from File1").Cells(i, 13).Copy
Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues
 
Upvote 0
Change to this:
VBA Code:
Worksheets("Download from File1").Cells(i, 13).Copy
Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues

I also have this piece of code where i want to use PasteSpecial....should i format in any other way.

erow = Worksheets("School Employee Info").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Download from File1").Paste Destination:=Worksheets("School Employee Info").Cells(erow + 1, 1)

I tried like this, but gives me an error

erow = Worksheets("School Employee Info").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Download from File1").Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues
 
Upvote 0
VBA Code:
erow = Worksheets("School Employee Info").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues
In between or just before you need to carry out the Copy (of something); you need to tell VBE what you going to Paste !
 
Upvote 0
VBA Code:
erow = Worksheets("School Employee Info").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("School Employee Info").Cells(erow + 1, 1).PasteSpecial Paste:=xlPasteValues
In between or just before you need to carry out the Copy (of something); you need to tell VBE what you going to Paste !
Thanks, it worked.
 
Upvote 0
Thanks for the positive feedback(y), glad having been of some help.
 
Upvote 0

Forum statistics

Threads
1,215,710
Messages
6,126,396
Members
449,312
Latest member
sweetfriend9

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