+ Reply to Thread
Results 1 to 7 of 7

Selecting a named range in VBA code

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Brighton, UK
    Posts
    79

    Selecting a named range in VBA code

    Hi guys,

    I have a template spreadsheet which has a macro in it that is accessed from another workbook. This template will eventially be about 30 different workbooks. I have this code:

    Please Login or Register  to view this content.
    I need the code on the line where it selects the "AFBP_text.xls" to select a range from a page in the workbook. The range is "Scriptname" and will be in every workbook.

    Obviously the scriptname range will change for each workbook, but the macro needs to run the same. So instead of manually changing which workbook it selects in the code for each new workbook I create from the template, I'm wondering if there is code to connect to this range automatically?

    Thank you in advance!

    Matt

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    have you tried
    Please Login or Register  to view this content.
    ?

    Your code is quite horrid (no personal insult, I'm sure you yourself are fully lovely). Perhaps you should google "writing better VBA".

    CC

  3. #3
    Registered User
    Join Date
    06-16-2008
    Posts
    32
    Quote Originally Posted by Cheeky Charlie View Post
    have you tried
    Please Login or Register  to view this content.
    ?

    Your code is quite horrid (no personal insult, I'm sure you yourself are fully lovely). Perhaps you should google "writing better VBA".

    CC
    Code seems to be generated by the macro recorder :P

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493
    Quote Originally Posted by gummi View Post
    Code seems to be generated by the macro recorder :P
    You think so ?

    Maybe another way
    Please Login or Register  to view this content.
    Last edited by davesexcel; 12-16-2008 at 10:15 AM.

  5. #5
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    agreed.

    Doesn't mean it has to stay horrid!

  6. #6
    Registered User
    Join Date
    07-09-2008
    Location
    Brighton, UK
    Posts
    79
    The code is horrid your right, it's a case of inheriting alot from previous users and also recording macro's to save time. It does the job, once I have everything in place I'll go through the code and tidy it up. To be honest, my job isn't to do this, I'm tidying up and saving time for current users on about 30 different main templates - then I do my own job. Which is why I ask you guys a fare few questions...

    So...

    Thank you very much for your continued help, I'm now going to type "writing better VBA" in google.

    Matt

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    hehe!

    I think I provided the solution you originally asked for - could you mark the thread as solved?

    CC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1