Protecting Sheets but allow Macro to run....

Ian1976

Board Regular
Joined
Feb 4, 2016
Messages
139
Office Version
  1. 365
Platform
  1. Windows
Hi I have the following code on a command button, the code runs on 2 other worksheets as well as this one - I need to protect the worksheets (formulas) but need the command button to still work, is that possible?

As I have tried several different methods and can't get one to work! Thanks

The 3 sheets are named as hawksworth, dibble & taylor

Sub NextSheet_Click()

Dim fname As String

Application.ScreenUpdating = False

'increment hawksworth days stopped including date and/or time


On Error Resume Next
Set cellrange1 = Range("N8:N47")
If Range("O1").Value = "1530" Then
Range("O1").Value = "0600"
Range("M1").Value = Range("M1").Value + 1
For Each cel In cellrange1
If cel.Value <> "" Then
cel.Value = cel.Value + 1
End If
Next
Set DateRange1 = Range("M8:M47")
For Each releasedate In DateRange1
If releasedate.Value <> "" Then
If releasedate.Value < Range("M1").Value Then
releasedate.Value = releasedate.Value + 1
End If
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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