variable

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 » Variable

Variable

resolvedResolved · Urgent Priority · Version 2003

Danielle has attended:
Excel VBA Intro Intermediate course

Variable

Hi there

I am trying to create a macro and it keeps de-bugging at this point. I am trying to select the whole table of information. If I hover of the IntNumRows it says it = 0, do I need to change the value of the IntTargetRow from 2 to 1?


IntTargetRow = 2
IntNumRows = Sheets("JPY TRADES").Range("A2").CurrentRegion.Rows.Count

Please advise as soon as possible.

Thanks
Danielle

RE: Variable

Hi Danielle, thanks for the query. Firsly, changing the value of the IntTargetRow from 2 to 1 in the code above won't make any difference because InTargetRow is not referenced in the code for IntNumRows. Secondly, make sure you cite the workbook name in the IntNumRows code and perhaps try bracketing it within a With Statement.

With Workbooks("workbook1.xls").Sheets("JPY TRADES")
.Range("a2").CurrentRegion.Rows.Count
End With

Also try the following:

Worksheets("Sheet1").Activate
ActiveCell.CurrentRegion.Select

...(note that it's the *Worksheets* object) and:

Range("A1").CurrentRegion.Select

...just to test that CurrentRegion is operating correctly, and if it is cannibalise the code if you need to. Lastly, the code may be falling over because of the space between "JPY" and "TRADES". A long shot, but try using an underscore, update the code and see what happens.

Let me know how you get on.

Anthony

Mon 3 Aug 2009: Automatically marked as resolved.

 

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:

Create and delete borders

To put a border around the outside of a selected range, press Ctrl+Shift+&. Use Ctrl+Shift+_ (underscore) to remove any borders from a range.

View all Excel hints and tips


Server loaded in 0.08 secs.