Paste to first empty cell after a specific cell

happydonut

Board Regular
Joined
Nov 28, 2019
Messages
57
Office Version
  1. 365
Platform
  1. Windows
Hey guys,

I want to copy a range from Sheet1 (example column F starting from row 2) and paste it in another column in Sheet2 in the first empty cell starting from B6. Can anyone help with the code?
What I have done so far, which not works:

VBA Code:
Dim ws as Worksheeet
Dim ws2 as Worksheet

Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")

Dim wsLR As Long, ws2LR As Long

wsLR = ws.Cells(Rows.Count, "A").End(xlUp).Row
ws2LR = ws2.Cells(Rows.Count, "A").End(xlUp).Row

    ws.Range("F2:F" & wsLR).Copy
    ws2.Range("B6:B" & ws2LR).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
51,757
Office Version
  1. 365
Platform
  1. Windows
What I have done so far, which not works:
Good to show us what you have tried, but just saying it doesn't work gives us little to go on. Best to say if it
- Gives an error? What error on what line?
- Crashes excel
- Does nothing
- Pastes in the wrong place? Where did it paste?
etc

In any case, give this a try

VBA Code:
Dim ws As Worksheet
Dim ws2 As Worksheet

Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")

Dim wsLR As Long, ws2LR As Long

wsLR = ws.Cells(Rows.Count, "F").End(xlUp).Row
If wsLR > 1 Then
ws2LR = ws2.Cells(Rows.Count, "B").End(xlUp).Row
If ws2LR < 5 Then ws2LR = 5
  ws.Range("F2:F" & wsLR).Copy
  ws2.Range("B" & ws2LR + 1).PasteSpecial xlPasteValues
  Application.CutCopyMode = False
End If
 

Forum statistics

Threads
1,147,823
Messages
5,743,409
Members
423,792
Latest member
travisds

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
Top