PDA

View Full Version : [SOLVED:] Runtime Err 91



GEORGE PERRY
03-08-2021, 09:03 AM
please my excel app is not running this is giving

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

28072


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

Paul_Hossler
03-08-2021, 09:42 AM
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

GEORGE PERRY
03-08-2021, 10:12 AM
thanks very much for your help and direction am much grateful

GEORGE PERRY
03-08-2021, 04:16 PM
Please my Excel app is still giving the below message and i am not getting it



28075

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