Imran has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course
Excel Advanced - Formulas & Functions course
Excel Advanced - For Power Users course
VBA Code not working
Hi,
I have a simple bit of VBA code that does not seem to give me an output. I am trying to copy the first two columns on sheet2 to first two columns in sheet1. I think that I am storing the values in a variable, but then I'm not actually pasting the values from the variable to sheet1. Do not quite remember how to do this.
Sub CopynPaste()
Dim CopyColumn(1 To 1000, 1 To 1000) As Variant
Worksheets("Sheet2").Activate
Cells(UBound(CopyColumn)).Copy
Sheets("sheet1").Activate
ActiveCell.PasteSpecial
Worksheets("Sheet2").Activate
ActiveCell.Offset(0, 2).Select
Worksheets("Sheet1").Activate
ActiveCell.Offset(0, 2).Select
End Sub
RE: VBA Code not working
Hi Imran
Good to hear from you. This isn't quite the right syntax. You might remember an exercise we did on the Advanced course which transferred data from one sheet to another. I've attached a working version of this for you to have a look at.
See if you can adapt this to your needs, and if you have any questions then let me know.
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector