+ Reply to Thread
Results 1 to 13 of 13

Subscript out of range

  1. #1
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Subscript out of range

    Hello,

    Need help to fix a code. I am trying to copy all the information from DFG, Geo tab of thisworkbook to Created workbook("DFG_" $environ("username"), doing so I am getting and subscript out of range error. I have underlined the code statement which seems to be incorrect.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Subscript out of range

    It means the sheet names do not exist, you need to check the spelling, including spaces.

  3. #3
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    Sheet exist. I checked again looks fine to me.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Subscript out of range

    If you are getting an error on this line

    With Workbooks("DFG").Sheets("Geo").Range("A1")

    It could be the Workbooks("DFG"). does not exist or it is not the active book( If you open two books at the same time), or the sheet name "Geo"with in sheet Workbooks("DFG") does not exist.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subscript out of range

    Replace Workbooks("DFG") with newbook.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    Thanks! It worked using Newbook .

    Now I am getting Application Defined or object error in

    Please Login or Register  to view this content.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subscript out of range

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

  8. #8
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    Thanks for all your help Norie! It worked like a charm.

    One more help, I am trying to attach the Exception_Template to "Exception" sheet of newfile. Getting an application or Object defined error. Am I going wrong somewhere.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    Any suggestions?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subscript out of range

    I'm not sure what you are trying to do.

    This line of code will create a copy of the sheet 'Exception_Template' in its own, new, workbook.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    What i am trying to achieve here copy the exception_template worksheet and paste it in the New worksheet of workbook "Newbook" where other 2 worksheets is already added - DFG & Geo.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subscript out of range

    If you want to copy a worksheet from one workbook to another specify the destination after Copy.
    Please Login or Register  to view this content.
    If you want to copy the data from a sheet in one workbook to a sheet in another try this.
    Please Login or Register  to view this content.
    If you want to hide the sheet you've copied/copied from do it after you've done the copy.

  13. #13
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Subscript out of range

    Thanks Again Norie, it worked perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 06-15-2015, 01:56 AM
  2. subscript out of range
    By josros60 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-17-2013, 06:33 PM
  3. Subscript out of Range
    By elavarasans in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2012, 11:45 AM
  4. Excel 2007 : Subscript out of range
    By ususgoreng in forum Excel General
    Replies: 3
    Last Post: 05-26-2011, 06:30 PM
  5. Subscript out of range error while populating array from range.
    By Aussiexile in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2010, 02:22 AM
  6. Subscript out of range error when trying to select a range
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2010, 07:57 PM
  7. Subscript out of range
    By mcukier in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-02-2009, 09:49 AM

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