+ Reply to Thread
Results 1 to 3 of 3

Error with an Array in a macro

  1. #1
    Registered User
    Join Date
    07-14-2008
    Location
    INDIA
    Posts
    78

    Error with an Array in a macro

    Hi,

    I am a starter in VBA. Below is apart of code in which I am getting run time error 13 at the bolded and the under lined line. Can I have some suggestions how to rectify this.
    Please Login or Register  to view this content.
    Any Help on where I am going wrong.

    Posted here also but invain:http://www.mrexcel.com/forum/showthread.php?t=388162
    Last edited by TRJJK73; 05-05-2009 at 05:41 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Error with an Array in a macro

    To answer your question...

    You must ReDim the Array before you can populate, eg pre j loop:

    Please Login or Register  to view this content.
    You will need to revise your n loop also to make use of the fact that the Array holds sheet names, ie:

    Please Login or Register  to view this content.
    IMO it's also a good habit to get into releasing Objects prior to End of Routine, eg:

    Please Login or Register  to view this content.
    An altogether alternative approach if this is all you're looking to do (ie colour range) would be:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-14-2008
    Location
    INDIA
    Posts
    78

    Re: Error with an Array in a macro

    Thank you DonkeyOte,

    This is from where I started learning VBA from people like you.

    Thank you once again for your valuable explanation.

+ 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