0
votes

I am new to vba and don't know how to code. I recorded a macro to copy specified cells from one sheet into cells in another sheet, but it keeps pasting into the same column and I want the paste to be into the next open column. This is all I have.

Sub Weekday() ' ' Weekday Macro '

Range("J10:J13").Select
Selection.Copy
Sheets("Results").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
2
Hint...using the recorder, try Ctrl+Right Arrow to find the last used column.Rdster

2 Answers

0
votes

If you change :

Range("C2").Select

by

c = Cells(2, 3).End(xlToRight).Column + 1
Cells(2, c).Select

c is an integer. It gives you the number of the next empty column in the row 2.

0
votes
With Sheets("Results")
    .Cells(2, .Columns.count).End(xlToLeft).Offset(, 1).Resize(4).Value = Range("J10:J13").Value
End With