Error 424 - Object required

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm getting 2 errors in the same module, which I think are connected.

The first one I get is 'Error 424 Object required' and this fails on line 40. The 2nd one I get is 'Error 91 Object variable or With block variable not set', which fails on line 140.

I've posted both in the same question because I strongly suspect they are linked - can anyone confirm and suggest a way to resolve it?

Code:
Dim Rng As RangeDim Rng2 As Range
Dim OL              As Object
Dim EmailItem       As Object


10    Set Rng = Nothing
20    Set Rng2 = Nothing
30    Set Rng = Sheet16.Range("A1:E27").SpecialCells(xlCellTypeVisible)
40    Set Rng2 = Sheet16.Range("A29:D31").SpecialCells(xlCellTypeVisible)
50    With Application
60    .EnableEvents = False
70    .ScreenUpdating = False
80    End With
90    Set OL = OutlookApp(olMaximized)
100   Set EmailItem = OL.CreateItem(olMailItem)
110   With EmailItem
120   .Subject = "Duty - " & Sheet8.Range("B2").Value & " Team " & Sheet8.Range("B3").Value & " (" & Sheet8.Range("B13").Value & " Shift " & Sheet8.Range("B17").Value & ")"
130   If Sheet16.Range("G1").Value = "YES" Then
140   .HTMLBody = RangetoHTML(Rng2) & RangetoHTML(Rng)
150   Else
160   .HTMLBody = RangetoHTML(Rng)
170   End If
180   .To = "Duty Mailbox"
190   .CC = ""
200   .BCC = ""
210   .Display
220   End With
230   Set OL = Nothing
240   Set EmailItem = Nothing
250   With Application
260   .EnableEvents = True
270   .ScreenUpdating = True
280   End With
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
My first thought would be there's no Sheet16 object but that would mean an error in line 30 as well. Another option would be the range "A29:D31" in Sheet16 to be hidden
 
Upvote 0

Forum statistics

Threads
1,213,511
Messages
6,114,054
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top