+ Reply to Thread
Results 1 to 2 of 2

Subscript out of Range

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    4

    Subscript out of Range

    Hi Experts,

    My requirement is explained below
    step 1: (Myfile) is active workbook-->Click Button-->open the Required workbook file -->from that file ,save all sheet name in combo-list box
    step 2: Now select sheet name from combo box-->selected sheetname will be paste to "myfile" workbook




    Mycode is below


    Please Login or Register  to view this content.
    -------------------------------------------------------------------




    '(Module1 code)
    Please Login or Register  to view this content.
    ---------------------------------------------------------

    'copy that particular tab in another file
    Please Login or Register  to view this content.
    ------------------------------------------------------------

    My problem is..

    for First time run --> code ran fine
    for Second time run--> am getting error "Subscript out of Range"
    only if i click reset button I am able to run


    This error because Windows(filename).Activate ,here where variable "filename" was initially empty while calling sub maincodeButton_click()
    Always for second run I have to Reset macro .....But i dont know how to over come...please solve my problem
    Last edited by arlu1201; 09-21-2012 at 11:45 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Subscript out of Range

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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