+ Reply to Thread
Results 1 to 4 of 4

Runtime error 91

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    11

    Runtime error 91

    Hi All,

    I have a problem with my code (which was ok until now). I got a Run-time error 91 message all the time when I am running the following code:

    Sub matchReport()
        Dim id As String
        Dim cmo_fmo As String
        Dim last_row, j As Integer
        Dim FileName As String
                                    
        ' get last row of this workbook
        last_row = ActiveSheet.UsedRange.Rows.Count + 1
                    
      
        Set Source = Workbooks.Open("k:\SDM Reporting\Reporting_BUD\EON_C\Report block\Ready reports\MCC_Tools\Gabor\Exh 3-A MCC 3.2.05 Office LAN WLAN Availability 2013.xlsx")
            
        j = 2
        Do While (Source.Sheets("Raw data").Cells(j, 1).Value <> "")
        
            ' get values from source
            id = Source.Sheets("Raw data").Cells(j, 1).Value
            cmo_fmo = Source.Sheets("Raw data").Cells(j, 4).Value
                  
                
            'find id
            ThisWorkbook.Activate
            Columns("E:E").Select
            Set cell = Selection.Find(What:=id, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
            
            ActiveSheet.Cells(cell.Row, 4).Value = cmo_fmo             'the issue is here
                 
            j = j + 1
        Loop
        Source.Close
        
        Columns("F:F").Select
        Selection.NumberFormat = "0.00%"
        Columns("H:K").Select
        Selection.NumberFormat = ""
        
        'MSGbox
        ActiveCell = MsgBox("Format procedure has been finished.", vbOKOnly, "Format has been finished in Weekly Report")
       
        
    End Sub
    Do you have any ideas why this is happening now? I have not changed the code only I have refreshed the raw data file, source is the same as before.

    Thank you in advance!

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

    Re: Runtime error 91

    In which line of the code do you get the error?

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

    Re: Runtime error 91

    The error is probably because id isn't being found, so cell is Nothing.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    01-08-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Runtime error 91

    Thank you for the quick answers!

    I have figured out the issue. An error handling was missing, so I implemented an IF THEN ELSE into the code.

+ 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. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  2. Defining Array - Runtime error 9, Subscript out of range error
    By MaartenW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2012, 07:32 AM
  3. runtime error 3265 error in a VBA Query to pull info from ERP Database
    By NBVC in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-12-2010, 03:59 PM
  4. Excel xmlHTTP object error message - system/runtime error
    By Porky2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2007, 09:36 AM
  5. Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 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