98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA Code not working
VBA Code not working
Resolved · Medium Priority · Version 2007
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
Attached files...
Thu 13 Feb 2014: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:3D formulas find and replaceAfter you know all the components of a 3D reference, you can change them to suit by using a localised Find and replace crt+f, if need be. |