Reputation: 133
I'm trying to create a Macro that copies variable columns from one sheet to another. For example I would like to copy column A-sheet 3 to column A-sheet 6, column B-sheet 3 to column C-sheet 6, etc.
I was hoping to create one procedure that can be called many times.
Sub Copy_Column(a, b)
Sheets(3).Select
Range("a11:a1000").Select
Selection.Copy
Sheets(6).Select
Range("b15").Select
ActiveSheet.Paste
End Sub
Sub Master()
Call Copy_Column(a, a)
End Sub
What happens is it copies Column A in sheet 3 to Column B in sheet 6, not in Column A.
Thanks in advance!
Upvotes: 0
Views: 742
Reputation: 78200
Well you never use the a
and b
parameters in the routine.
Did you mean them to represent column letters? If so, then
Sub Copy_Column(byval a as string, byval b as string)
Sheets(3).Range(a & "11:" & a & "1000").Copy Sheets(6).Range(b & "15")
End Sub
Sub Master()
Call Copy_Column("a", "a")
End Sub
Upvotes: 1