fredlo2010
05-22-2012, 11:17 AM
Hello,
I have this code that's supposed to go to the sheet Systems select cell A1 and expand the selection till the last cell with content. Then copy move to sheet " Appendix Data" and paste it there.
Here is my code and it works fine
Sub AddSystems()
ActiveWorkbook.Sheets("Systems").Activate
Range("A1", Range("A65536").End(xlUp)).Select
Selection.Copy
ActiveWorkbook.Sheets("Appendix Data").Activate
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
The issue comes up when I try to modularize it. I want to assign my cell A1 to a variable so I can call the main sub every time i want and change the value.
when I run it i get the error: Expected Funcion or variable.
Any ideas???
here is my code
Sub AddSystems(varColumns As String)
ActiveWorkbook.Sheets("Systems").Activate
Range(varColumns, Range("A65536").End(xlUp)).Select
Selection.Copy
ActiveWorkbook.Sheets("Appendix Data").Activate
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
Sub lets()
Run AddSystems("A1")
End Sub
Thanks a lot
I have this code that's supposed to go to the sheet Systems select cell A1 and expand the selection till the last cell with content. Then copy move to sheet " Appendix Data" and paste it there.
Here is my code and it works fine
Sub AddSystems()
ActiveWorkbook.Sheets("Systems").Activate
Range("A1", Range("A65536").End(xlUp)).Select
Selection.Copy
ActiveWorkbook.Sheets("Appendix Data").Activate
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
The issue comes up when I try to modularize it. I want to assign my cell A1 to a variable so I can call the main sub every time i want and change the value.
when I run it i get the error: Expected Funcion or variable.
Any ideas???
here is my code
Sub AddSystems(varColumns As String)
ActiveWorkbook.Sheets("Systems").Activate
Range(varColumns, Range("A65536").End(xlUp)).Select
Selection.Copy
ActiveWorkbook.Sheets("Appendix Data").Activate
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
Sub lets()
Run AddSystems("A1")
End Sub
Thanks a lot