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 » Macro error
Macro error
Resolved · Urgent Priority · Version 2016
Carolina has attended:
Excel Intermediate course
Excel Advanced course
Excel Advanced course
Excel VBA Introduction course
Excel VBA Intermediate course
Macro error
Hi! I am frequently using a macro that usually works, but a few times it gives me an error.
The macro (which we call RAWSqtoCol) picks up all data points that are on a data square called “Raw Data” that goes from cell B6:K59 and transposes them to a column next to it, in AL. Although it has always worked fine, lately we have been having problems with the macro (in spite of the fact that the code of the macro remains exactly the same).
When cells B59 and C59 contain the value 1.0 the RAWSqtoCol macro will not pick them up. This only happens in this row, as there are other rows that contain the value 1.0 and this is picked up. If we change the values inside those cells (e.g. from 1.0 to 2.0 or from 1.0 to . – the latter means missing data point for us-), the macro will pick them up again and correctly place them on the transposed AT column.
It would be great if you could have a look at this and see if you catch anything that is not correctly done. Shall I send you the file?
Thank you for your assistance!
Best,
Carolina
RE: Macro error
Hi Caroline,
Thank you for the forum question.
Yes please send me the file.
jens.bonde@stl-training.co.uk
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
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
RE: Macro error
Hello Carolina,
Thank you for your question. Please could you send us a sample copy of the Excel file with the code so that we can best answer your question. You can send it to:
forum@stl-training.co.uk
We look forward to hearing from you.
Kind regards
Marius Barnard
STL
RE: Macro error
Hi Carolina,
It is you If, which gives you the problem.
I have amended the code and as far as I can see it will do the job right.
Sub RAWSqtoCol()
Dim rngIn As Range
Dim rngOut As Range
Dim rngX As Range
MsgBox "Please place active cell on AL6"
Set rngIn = Range("B6:K59")
For Each rngX In rngIn.Columns
Set rngOut = Range("AL" & Rows.Count).End(xlUp).Offset(1, 0)
rngX.Copy
rngOut.PasteSpecial Transpose:=False
Next
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
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
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:Change the Print button so it brings up the Print dialogue boxIf you want to bring up the Print dialogue box to check your print settings when you hit the Print button, do the following: |