macro error

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Macro error

Macro error

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

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 box

If you want to bring up the Print dialogue box to check your print settings when you hit the Print button, do the following:

1. Right-click on the toolbar that displays the Print button.

2. Select Customise.

3. Click on the Print button on the toolbar to select it, then hold the left mouse button down and drag the button towards the screen below. The button should come off the toolbar.

4. In the Customise dialogue box on your screen, select the Commands tab.

5. Select File from the Categories list, and then locate the Print... icon (looks like the normal Print button, but the word Print has three dots following it).

6. Click on the Print... icon to select it, then use your left mouse to drag and drop the icon onto the toolbar at the top of the screen.

7. Close the Customise dialogue box.

View all Excel hints and tips


Server loaded in 0.09 secs.