Monu
Monu

Reputation: 47

Macro to Copy and paste from one sheet into next open column in another sheet

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

Upvotes: 0

Views: 640

Answers (2)

user3598756
user3598756

Reputation: 29421

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

Upvotes: 0

D. O.
D. O.

Reputation: 626

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.

Upvotes: 0

Related Questions