Pairing columns (copying and pasting on specified row)

Smilin

Board Regular
Joined
Nov 28, 2019
Messages
67
Platform
  1. Windows
Please help ?

I am using the following VBA for copying and pasting from Column A (Sheet1) to 1st available row on (OCT-DEC-2019) worksheet.

Public Sub QUARTER4()

'define source range

Dim SourceRange As Range

Set SourceRange = ThisWorkbook.Worksheets("Sheet1").Range("A2:A600")

'find next free cell in destination sheet

Dim NextFreeCell As Range

Set NextFreeCell = ThisWorkbook.Worksheets("OCT-DEC 2019").Cells(Rows.Count, "A").End(xlUp).Offset(RowOffset:=1)

'copy & paste

SourceRange.Copy

NextFreeCell.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

For the other columns from Sheet1, I need to paste them on the same row that Column A1 was pasted to. EX if Column A from sheet 1 was copied and pasted to column A, starting on Row 34 of OCT-DEC 2019 sheet, as this was the 1st empty row, then I need the next column B( or C, D etc) copied and pasted starting on Row 34 as well in column B (or C, D, etc). Hope this makes sense. Many sincere, grateful thanks.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try this

If you are only working with only one book, it is not necessary to put Thisworkbook.

VBA Code:
Public Sub QUARTER4()
  'define source range
  Dim lastRow As Long
  
  With Worksheets("OCT-DEC 2019")
    lastRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    Worksheets("Sheet1").Range("A2:A600").Copy
    .Range("A" & lastRow).PasteSpecial Paste:=xlValues
    
    Worksheets("Sheet1").Range("B2:B600").Copy
    .Range("B" & lastRow).PasteSpecial Paste:=xlValues
  
    Worksheets("Sheet1").Range("C2:C600").Copy
    .Range("C" & lastRow).PasteSpecial Paste:=xlValues
  End With
End Sub
______________________________
If you are going to copy several columns you can do it in a single line:
VBA Code:
Public Sub QUARTER4()
  'define source range
  Dim lastRow As Long
  
  With Worksheets("OCT-DEC 2019")
    lastRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    Worksheets("Sheet1").Range("A2:C600").Copy
    .Range("A" & lastRow).PasteSpecial Paste:=xlValues
  End With
End Sub

They can even be discontinuous columns:

VBA Code:
Public Sub QUARTER4()
  Worksheets("Sheet1").Range("A2:A600, C2:C600, E2:E600").Copy
  Worksheets("OCT-DEC 2019").Range("A" & Worksheets("OCT-DEC 2019").Range("A" & Rows.Count).End(xlUp).Row + 1).PasteSpecial Paste:=xlValues
End Sub
 
Upvote 0
Gratitude Dante!! I put it to use right away and it works, Muchly appreciate this. I know I will be back with more questions.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,689
Members
449,117
Latest member
Aaagu

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