Simple question: copy/paste column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a simple question that I cannot find an answer to:

I have two Range variables, which are columns. I'd like to copy them and
paste them on to a new worksheet...
 
Hi H,

Try something like:

'=============>>
Public Sub Tester1()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim srcRng As Range
Dim destRng As Range

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE

With WB
Set srcSH = .Sheets("Sheet2") '<<==== CHANGE
Set destSH = .Sheets("Sheet3") '<<==== CHANGE
End With

With srcSH
Set srcRng = Union(.Columns("A:A"), .Columns("C:C"))
End With

Set destRng = destSH.Range("A1")
srcRng.Copy Destination:=destRng

End Sub
'<<=============
 
Dim r1 as Range, r2 as Range
With ActiveSheet
set r1 = .Columns(1)
set r2 = .columns(9)
End With
r1.copy worksheets("Sheet2").Range("B1")
r2.copy worksheets("Sheet2").Range("F1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top