troubleshooting Question

Using a variable in a VB Excel macro

Avatar of christiemhjohnson
christiemhjohnson asked on
Microsoft ExcelMicrosoft Development
6 Comments2 Solutions3501 ViewsLast Modified:
I am writing a VB macro in Microsoft Excel which automatically creates a pivot table from two tabs within the spreadsheet.  This macro will be used multiple times, each time with a different amount of data in it, in turn, I need to make the macro dynamic so that it will read in more or less data each time.    I have written a loop to find the last row in my spreadsheet and saved that number as a variable (r or f)  I want to use that variable in range type lines of code, but don't think I am doing it correctly.  

For example, currently, I have
RANGE("F2:F10896").select

However, the next time this is run there will be more than 10896 records, so I need that to be dynamic.  I can't imagine that I can use the following code:

RANGE("F2:FT").select

This is extremely important, so I can assure you an A and max points.  
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros