VBA copy paste into new range

ChelseaH

New Member
Joined
Feb 11, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi,
I have the below code that copy and pastes full rows from one sheet to another based on certain criteria. It's currently pasting into column A on the next blank row but I would like it to paste in column B. I've taken this from a sheet I created years ago so apologies if it's messy! Is anyone able to help please?


Private Sub CommandButton1_Click()

a = Worksheets("time analyser").Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To a

If Worksheets("time analyser").Cells(i, 2).Value = "BaU 2022 - Fortnightly planning calls (strat support)" Then

Worksheets("time analyser").Rows(i).Copy
Worksheets("BAU strategic support").Activate
B = Worksheets("BAU strategic support").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("BAU strategic support").Cells(B + 1, 1).Select
ActiveSheet.Paste
Worksheets("time analyser").Activate

End If
Next

Application.CutCopyMode = False

ThisWorkbook.Worksheets("time analyser").Cells(1, 1).Select

MsgBox ("Fortnightly planning calls ready")

End Sub

Thank you!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Maybe changing this
VBA Code:
Worksheets("BAU strategic support").Cells(B + 1, 1).Select
To this:
VBA Code:
Worksheets("BAU strategic support").Cells(B + 1, 2).Select
 
Upvote 0
Thank you, when I try that I get: 'Runtime error 1004. You can't paste this here because the copy and paste area aren't the same size.'
Thanks for your help!
 
Upvote 0
Hi & welcome to MrExcel.
You cannot copy an entire row & paste it starting in col B as it would extend off the edge of the sheet. What is the range you need to copy?
 
Upvote 0
Hi & welcome to MrExcel.
You cannot copy an entire row & paste it starting in col B as it would extend off the edge of the sheet. What is the range you need to copy?
Thanks Fluff, I did not know that either.
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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