Paste range to first column, then next blank column

horizonflame

Board Regular
Joined
Sep 27, 2018
Messages
186
Office Version
  1. 2013
Hi All,

I have found my formula for pasting a copied range to the next blank column, but need some help if the next blank column is the first column in the sheet. With my current formula it pastes to column B not A.

Sheets("DataRaw").Select
Application.Goto Reference:="R2C1:R7000C2,R2C7:R7000C7"
Selection.Copy

Sheets("DatesRaw").Range("A3").End(xlToLeft).Offset(0, 1).PasteSpecial xlValues
Application.CutCopyMode = False

Many thanks :)
 
Last edited:

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.
Hi,
How about this?

Code:
DIM LastCol&
Dim OffsetNo&
Sheets("DataRaw").Select
Application.Goto Reference:="R2C1:R7000C2,R2C7:R7000C7"
Selection.Copy

LastCol=Sheets("DatesRaw").Range("A3").End(xlToLeft).Column
If LastCol = 1 and Sheets("DatesRaw").Range("A1")="" then
    OffsetNo=0
Else
    OffsetNo=1
End if
Sheets("DatesRaw").Range("A3").End(xlToLeft).Offset(0, OffsetNo).PasteSpecial xlValues
Application.CutCopyMode = False
 
Upvote 0
This line
Code:
Sheets("DatesRaw").Range("A3").End(xlToLeft).Offset(0, 1).PasteSpecial xlValues
will paste into B3 regardless of how many columns have data.
Will row 3 always have data?
 
Upvote 0
In that case try
Code:
With Sheets("DatesRaw")
   If .Cells(3, 1) = "" Then
      .Cells(3, 1).PasteSpecial xlPasteValues
   Else
      .Cells(3, Columns.Count).End(xlToLeft).Offset(, 1).PasteSpecial xlPasteValues
   End If
End With
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
My pleasure. I'm glad we could help you. Thansk for you feedback :)
 
Upvote 0

Forum statistics

Threads
1,224,943
Messages
6,181,922
Members
453,071
Latest member
Gizmo2024

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