Consulting

Results 1 to 4 of 4

Thread: Runtime Err 91

  1. #1

    Runtime Err 91

    please my excel app is not running this is giving

    run time error '91':
    object variable or with block variable is not set

    Screenshot (15).jpg

    dsh.AutoFilterMode = False
    
    dsh.Range("H:").NumberFormat = "dd-mm-yyyy"
    
    
    '''''''''Put filter here''''''
    
    dsh.UsedRange.AutoFilter 8, ">=" & Me.txt_Start_Date.Value, xlAnd, "<=" & Me.txt_End_Date.Value
    
    If Me.OptionButton3.Value = True Then
    
        dsh.UsedRange.AutoFilter 3, "Purchase"
    End If
    
    If Me.OptionButton2.Value = True Then
        dsh.UsedRange.AutoFilter 2, "Sale"
    End If
    
    sh.UsedRange.Clear
    
    dsh.UsedRange.Copy
    sh.Range("A1").PasteSpecial xlPasteValuesAndNumbersFormat
    
    dsh.AutoFilterMode = False
    Last edited by Paul_Hossler; 03-08-2021 at 09:37 AM.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    1. I move your post to it's own thread since it didn't appear to have anything to do with 32/64 bit issues

    2. I added CODE tags around your macro - you can use the [#] icon to add them

    3. It's hard to read just a screen shot, but it looks like you

    Dim dsh as worksheet

    but

    but never Set dsh = ....


    However, it does appear that you Set sh = .... twice
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    thanks very much for your help and direction am much grateful

  4. #4

    Could not set the RowSource Property . invalid property value

    Please my Excel app is still giving the below message and i am not getting it
    
    
    
    Screenshot (19).jpg
    
    Run time error '380':
    
    dsh.UsedRange.AutoFilter 8, ">=" & Me.txt_Start_Date.Value, xlAnd, "<=" & Me.txt_End_Date.Value
    
    If Me.OptionButton3.Value = True Then
    
        dsh.UsedRange.AutoFilter 3, "Purchase"
    End If
    
    If Me.OptionButton2.Value = True Then
        dsh.UsedRange.AutoFilter 2, "Sale"
    End If
    
    sh.UsedRange.Clear
    
    dsh.UsedRange.Copy
    sh.Range("A1").PasteSpecial xlPasteValuesAndNumbersFormats
    dsh.AutoFilterMode = False
    
    '''''''''Display Data in Listbox'''''''
    
     Dim lr As Long
     lr = Application.WorksheetFunction.CountA(sh.Range("A:A"))
     
     If lr = 1 Then lr = 2
     
    With Me.ListBox2
        .ColumnCount = 8
        .ColumnHeads = True
        .ColumnWidths = "30,100,50,50,50,50,50,50"
        .RowSource = sh.Name & "!A2:H" & lr
    Attached Images Attached Images
    Last edited by GEORGE PERRY; 03-08-2021 at 04:28 PM. Reason: wrong information

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •