
08-07-2003, 12:17 PM
|
|
Contributor
* Expert *
|
|
Join Date: Mar 2003
Location: Adelaide,Australia
Posts: 681
|
|
This should copy the specified columns of a table in Sheet2 assuming your table is in Columns A and B starting from A1.
Code:
Sub cpyColumns()
'assumes column references in Sheet2 format in cellA1 "B" & cellB1 "A"
'copies column combinations until a blank cell in sheet2 columnA is found
Dim cpy As String
Dim pst As String
Dim rw As Long
For rw = 1 To Sheet2.Range("A1").End(xlDown).Row
cpy = Sheet2.Cells(rw, 1)
pst = Sheet2.Cells(rw, 2)
Sheet1.Columns(cpy & ":" & cpy).Copy Sheet3.Columns(pst & ":" & pst)
Next
Application.CutCopyMode = False
End Sub
|
|