VBA: Paste column range in another column in the first empty cell

wjeil

New Member
Joined
Feb 25, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a question, and hopefully someone can help me out.

Range("A2:A5").Select
Selection.Copy
Range("F1").Select
ActiveSheet.Paste
Range("A2:A5").Select
Selection.ClearContents
Sheets("Input_Batches").Select

I want to adjust the above copy paste command in VBA, so that it selects the first empty column of F. So that means if F1 till F10 e.g. already have a value/text. It has to copy the range in F11.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You can also simplify your code a bit by getting rid of all those SELECTs, which are not necessary, i.e.
VBA Code:
Range("A2:A5").Copy Cells(Rows.Count, "F").End(xlUp).Offset(1,0)
Range("A2:A5").ClearContents

or even simpler yet, just this one line of code (using CUT instead of COPY, since you want to clear the original data anyway):
VBA Code:
Range("A2:A5").Cut Cells(Rows.Count, "F").End(xlUp).Offset(1, 0)
 
Upvote 0
Solution
Perfect thanks. And how if i want to copy the range to another worksheet (tab)?
 
Upvote 0
Perfect thanks. And how if i want to copy the range to another worksheet (tab)?
I think you should just be able to preface the copy range with the sheet name, i.e.
Rich (BB code):
Range("A2:A5").Cut Sheets("sheetname").Cells(Rows.Count, "F").End(xlUp).Offset(1, 0)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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