Results 1 to 6 of 6

runtime error 9 subscript out of range

Threaded View

Ted871 runtime error 9 subscript out... 09-19-2013, 05:38 PM
Norie Re: runtime error 9 subscript... 09-19-2013, 05:44 PM
Ted871 Re: runtime error 9 subscript... 09-20-2013, 02:34 AM
Debraj Roy Re: runtime error 9 subscript... 09-20-2013, 02:53 AM
Ted871 Re: runtime error 9 subscript... 09-21-2013, 06:28 AM
Debraj Roy Re: runtime error 9 subscript... 09-21-2013, 06:33 AM
  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    3

    Angry runtime error 9 subscript out of range

    Hello Forumers!

    I would like to ask your help as I am struggling with this case for days and I cannot figure out what can cause this "runtime error 9 subscript out of range error". I would give some detail before the code.

    There are two files "A.xlsm" and "B.xls". File "A" is open (this is where I would like to run my macro from on file "B") and "B" should be opened and a specific worksheet called "data" should be activated and copied every data from that sheet row by row to file "A" if a colum value is a special word. In file "A" at the start I create a sheet with the current date which is important for me to stay this way. This sheet is totally empty.

    The code:

    Sub copy_between_files()
    Dim curr_date As String
    Dim intRow
    Dim intLastRow
    
    curr_date = Format(Now(), "mm-dd-yy")
    
    Sheets.Add After:=Sheets(Sheets.Count) 'inserts the current date labeled worksheet into file A
        Worksheets(Worksheets.Count).Activate
        ActiveSheet.Name = curr_date
        
    Workbooks.Open Filename:="C:\Macros\B.xls" 'opens the datasource file
        
    Windows("B.xls").Activate 
    
    Sheets("Data").Select 'selecting the special sheet in file B
    
    intLastRow = ActiveSheet.UsedRange.Rows.Count
    
        Range("A1").Select
    
        For intRow = 1 To intLastRow Step 1
            Rows(intRow).Select
            If Cells(intRow, 5).Value = "specialword" Then
                                           Cells(intRow, 1).Select
                                           Selection.EntireRow.Copy
                                           Windows("A.xlsm").Activate
                                           Sheets(curr_date).Select
                                           Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
                                           ActiveSheet.Paste
            End If
            Windows("B.xls").Activate
            Sheets("Data").Select
        Next intRow
    
    Windows("A.xlsm").Activate
    
    End Sub
    If there would be any guesses , hints or advice I would really appreciate it! I hope my description can be used to guide you to my problem.
    Last edited by Ted871; 09-20-2013 at 02:32 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Runtime error 9: subscript out of range..
    By daveyc18 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-19-2013, 03:02 PM
  2. Runtime error '9' Subscript out of range
    By mickinho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2013, 03:00 AM
  3. Runtime Error 9: Subscript out of Range
    By murugavelmsc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2011, 12:33 AM
  4. [SOLVED] Runtime Error '9' Subscript out of range HELP
    By Brandon Johnson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2006, 01:50 PM
  5. Runtime Error 9 Subscript out of Range
    By TQO23 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-02-2005, 09:42 PM

Tags for this Thread

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