We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide

VBA Code

Hi All
Can anyone help with an excel VBA problem i have?

In column A I have a list of names. I have named A1 as range and use this to open another file, do some copying and pasting and then close. Now I need to loop down col A to do the same for A2 and so on, but hit a wall when the code goes back to the range for opening the next file, as it is still showing the name connected to A1.

Is there some way of naming the entire col A as the range but going through them one by one?

Any help is much appreciated.

Thanks

Comments

  • bluesnake
    bluesnake Posts: 1,460 Forumite
    Not vba, but think this could be got working using something like EZmacros
  • esuhl
    esuhl Posts: 9,409 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    I haven't used VBA for ages, but rather than specify named ranges, why not refer to the cells by row & column ordinates? Then you can use a variable for the row number and a for loop to iterate through each one.

    If you do a quick web search, there are examples of small functions you could write to identify the last populated row/column in a worksheet, which could be used as the upper bound in the for loop, if necessary.
  • Thanks for the replies - I have found a solution which is similar to esuhl's suggestion.

    Cheers
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 354K Banking & Borrowing
  • 254.3K Reduce Debt & Boost Income
  • 455.3K Spending & Discounts
  • 247K Work, Benefits & Business
  • 603.7K Mortgages, Homes & Bills
  • 178.3K Life & Family
  • 261.2K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.