-
WSDon_Sadler
AskWoody LoungerWhen I get that Object required error, the code that is highlighted is:
For Each rngarea In myRange.Areas
-
WSDon_Sadler
AskWoody LoungerBe sure to close “With myRange” with an “End With”; I didn’t in the above example, so I have edited it.
I had already added that End With and now I have error that says Run-time Error ‘424’:Object Required. the code in use now is:
Code:Sub Resetvalues() ActiveSheet.Unprotect Dim wsh As Worksheet Set wsh = Worksheets("EVENT-Work") myRange = Range("B9:B110, H9:H110, O9:O110") With myRange For Each rngarea In myRange.Areas For Each rngcell In rngarea With rngcell If .Value vbEmpty Then .Value = "0" End With Next rngcell Next rngarea End With Application.ScreenUpdating = True ActiveSheet.Protect End Sub
-
WSDon_Sadler
AskWoody LoungerBe sure to close “With myRange” with an “End With”; I didn’t in the above example, so I have edited it.
I had already added that End With and now I have error that says Run-time Error ‘424’:Object Required. the code in use now is:
Sub Resetvalues()
ActiveSheet.Unprotect
Dim wsh As Worksheet
Set wsh = Worksheets(“EVENT-Work”)
myRange = Range(“B9:B110, H9:H110, O9:O110”)
With myRange
For Each rngarea In myRange.Areas
For Each rngcell In rngarea
With rngcell
If .Value vbEmpty Then .Value = “0”
End With
Next rngcell
Next rngarea
End With
Application.ScreenUpdating = True
ActiveSheet.Protect
End Sub -
WSDon_Sadler
AskWoody LoungerNo, the mistake was mine, see your private messages.
You still need to use the Next statements in the loops:
Code:With myRange For Each rngarea In myRange.Areas For Each rngcell In rngarea With rngcell If .Value vbEmpty Then .Value = "0" End With Next rngcell Next rngarea
Does this help?
I think it is getting closer although now I get a Compile Error: Expected End With
-
WSDon_Sadler
AskWoody LoungerYou read the post before I cleaned up some edits, see my revision.
When you use a “For Each Item in Parent.Items” loop, you don’t need the counter, see the VBA Help. (As an added bonus, VBA automatically releases the Item object so you don’t have to set it to = Nothing to close your Sub.)
And how about If .Value vbEmpty
(or you might try If .Value vbNull, don’t remember the exact difference.)
(Edit: did you delete a post, or am I sleep deprived?)
I must have deleted a post inadvertently – I am still not quite used to this forum and the posting/editing procedures. I tried that code and kept getting errors… finally, I am using the following yet I continue to get a For without next error… I went through several variations and continued to get End With errors, or expected End With errors. I am confused about why it is not looking and where/when End With and For/Next are needed.
Sub Resetvalues()
ActiveSheet.Unprotect
Dim wsh As Worksheet
Dim btn As Shape
Set wsh = Worksheets(“EVENT-Work”)
myRange = Range(“B9:B110, H9:H110, 09:O110”)With myRange
For Each rngArea In myRange.Areas
For Each rngCell In rngArea
With rngCell
If .Value = vbEmpty Then .Value = “0”
End With
Application.ScreenUpdating = True
Range(“h3”).Select
ActiveSheet.Protect
End Sub -
WSDon_Sadler
AskWoody LoungerI don’t have to have a For i= 1 to n statement?
Also, what I want to do is to assign a zero only if the cell is not empty… so is there a NotvbEmpty?
You read the post before I cleaned up some edits, see my revision.
When you use a “For Each Item in Parent.Items” loop, you don’t need the counter, see the VBA Help. (As an added bonus, VBA automatically releases the Item object so you don’t have to set it to = Nothing to close your Sub.)
And how about If .Value vbEmpty
(or you might try If .Value vbNull, don’t remember the exact difference.)
(Edit: did you delete a post, or am I sleep deprived)
(Further Edit – apologies, Don, I mistakenly hit the Edit button on your post, thinking I was replying.) -
WSDon_Sadler
AskWoody LoungerDon,
I click on the shape and then type the name directly into the names box at the upper left hand corner.
Doe this work for you?
Yes, this does work now – it didn’t before, though… I must have done something wrong. Thanks for the fast response.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
-
WSDon_Sadler
AskWoody LoungerThank you so much – of course those are the correct formulas to do it – why didn’t I see that initially? I must have a circular reference issue in my head.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
51 minutes ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
1 hour, 13 minutes ago -
Outdated Laptop
by
jdamkeene
6 hours, 17 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
11 hours, 42 minutes ago -
Another big Microsoft layoff
by
Charlie
11 hours, 22 minutes ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
2 hours, 19 minutes ago -
May 2025 updates are out
by
Susan Bradley
11 hours, 46 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
17 hours, 25 minutes ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
17 hours, 27 minutes ago -
Drivers suggested via Windows Update
by
Tex265
17 hours, 18 minutes ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
15 hours, 2 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
1 day ago -
Apple releases 18.5
by
Susan Bradley
18 hours, 43 minutes ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
1 day, 1 hour ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
1 day, 2 hours ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
9 hours, 37 minutes ago -
No HP software folders
by
fpefpe
1 day, 10 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
7 hours, 22 minutes ago -
Stay connected anywhere
by
Peter Deegan
1 day, 15 hours ago -
Copilot, under the table
by
Will Fastie
1 day, 6 hours ago -
The Windows experience
by
Will Fastie
1 day, 21 hours ago -
A tale of two operating systems
by
Susan Bradley
1 hour, 53 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
2 days, 2 hours ago -
Where’s the cache today?
by
Up2you2
2 days, 18 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 days, 11 hours ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
1 day, 11 hours ago -
Blocking Search (on task bar) from going to web
by
HenryW
13 hours, 39 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
3 days, 11 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
3 days, 11 hours ago -
regarding april update and may update
by
heybengbeng
3 days, 13 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.