Code to reset multiple sheets on one workbook

Helix242

Board Regular
Joined
Jun 28, 2016
Messages
78
Hi all,

I hope you can help as I am a bit bemused! I am trying to reset cells on two different Sheets on the one Workbook. The item to reset to "OPEN" on the BLT sheet is resetting on the Decking sheet. Can anyone help? Thanks in advance!

Private Sub Button51_Click()

If MsgBox("Choose OK to reset this page.", vbOKCancel) = vbOK Then
Application.EnableEvents = False
With Sheets("Decking")
Range("B4,B5,B10,F3,F4,F5,F9,F10,F12,F13,F14,F15,F16,F20,H3,H4,B22,C22").Value = ""
Range("B34").Value = "=H38"
Range("C34").Value = "=H95"
Range("C4").Value = "NO"
Range("C5").Value = "NO"
End With


With Sheets("BLT")
Range("b4").Value = "OPEN"


End With


Application.EnableEvents = True
Else
Exit Sub
End If
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
At the moment everything is working on the activesheet, because you haven't fully qualified your ranges.
Try
Code:
With Sheets("Decking")
   .Range("B4,B5,B10,F3,F4,F5,F9,F10,F12,F13,F14,F15,F16,F20,H3,H4,B22,C22").Value = ""
   .Range("B34").Value = "=H38"
   .Range("C34").Value = "=H95"
   .Range("C4").Value = "NO"
   .Range("C5").Value = "NO"
End With


With Sheets("BLT")
   .Range("b4").Value = "OPEN"
End With
 
Upvote 0
At the moment everything is working on the activesheet, because you haven't fully qualified your ranges.
Try
Code:
With Sheets("Decking")
   .Range("B4,B5,B10,F3,F4,F5,F9,F10,F12,F13,F14,F15,F16,F20,H3,H4,B22,C22").Value = ""
   .Range("B34").Value = "=H38"
   .Range("C34").Value = "=H95"
   .Range("C4").Value = "NO"
   .Range("C5").Value = "NO"
End With


With Sheets("BLT")
   .Range("b4").Value = "OPEN"
End With

Thank you so much for your help! Such a silly thing to miss out. Thanks once again :)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,788
Messages
6,180,953
Members
453,009
Latest member
lorbieckit

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