Password Protection for a MACRO

Northern NY Design

New Member
Joined
Sep 24, 2024
Messages
25
Office Version
  1. 365
Platform
  1. Windows
I am trying to make my MACRO (s) so that when someone clicks it they are prompted to enter "YES". I have read numerous threads on this but I cannot seem to make it work.

Below is the code for my MACRO, please show me where, and what to enter. Thank you in advance.

Sub CLEARROW18()
'
' CLEARROW18 Macro
' Use this MACRO to remove a driver from ROW 18 of the CURRENT DRIVER DATA without removing formulas or harming this spreadsheet set.
'
Sheets("CURRENT DRIVER DATA").Select
ActiveSheet.Unprotect
Range("A20:C20").Select
Selection.ClearContents
Range("E20").Select
Selection.ClearContents
Range("G20:AC20").Select
Selection.ClearContents
Range("AE20:AF20").Select
Selection.ClearContents
Range("AG20:AN20").Select
Selection.ClearContents
Range("AS20:AZ20").Select
Selection.ClearContents
Range("BE20:BL20").Select
Selection.ClearContents
Range("BQ20:BX20").Select
Selection.ClearContents
Range("CC20:CJ20").Select
Selection.ClearContents
Range("CO20:CV20").Select
Selection.ClearContents
Range("DA20:DH20").Select
Selection.ClearContents
Range("DM20:DT20").Select
Selection.ClearContents
Range("DY20:EF20").Select
Selection.ClearContents
Range("EK20:ER20").Select
Selection.ClearContents
Range("EW20:FD20").Select
Selection.ClearContents
Range("FI20:FP20").Select
Selection.ClearContents
Range("C20").Select
Sheets("CURRENT DRIVER DATA").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub
 
Make sure that all your lines of code are between the If and End If lines of code.
WOWOWOW.... I completely missed the "YOUR TEXT HERE" que... it works now... I am going to rest my simple little brain now. Thank you so much for your help.
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Last thing. I am trying to make the message window display different font colors and bold for certain information. Can someone assist?

VBA Code:
Sub SORTCURRENTDRIVERDATA()
'
If MsgBox("This is your friendly Lon-bot, reminding you that if you click YES, the CURRENT DRIVER DATA tab will be resorted into alphabetical order by driver first name. DO NOT DO THIS IN THE MIDDLE OF A WEEK, doing so may make your store data on each daily tab line up to the incorrect driver. THIS CANNOT BE UNDONE", vbYesNo) = vbYes Then
'
' SORTCURRENTDRIVERDATA Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
Range("A3").Select

ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 36
ActiveWindow.ScrollColumn = 45
ActiveWindow.ScrollColumn = 61
ActiveWindow.ScrollColumn = 75
ActiveWindow.ScrollColumn = 84
ActiveWindow.ScrollColumn = 87
ActiveWindow.ScrollColumn = 90
ActiveWindow.ScrollColumn = 95
ActiveWindow.ScrollColumn = 98
ActiveWindow.ScrollColumn = 106
ActiveWindow.ScrollColumn = 111
ActiveWindow.ScrollColumn = 117
ActiveWindow.ScrollColumn = 121
ActiveWindow.ScrollColumn = 124
ActiveWindow.ScrollColumn = 130
ActiveWindow.ScrollColumn = 132
ActiveWindow.ScrollColumn = 135
ActiveWindow.ScrollColumn = 139
ActiveWindow.ScrollColumn = 144
ActiveWindow.ScrollColumn = 150
ActiveWindow.ScrollColumn = 154
ActiveWindow.ScrollColumn = 158
ActiveWindow.ScrollColumn = 160
ActiveWindow.ScrollColumn = 162
ActiveWindow.ScrollColumn = 166
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 37
ActiveWindow.ScrollRow = 52
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 56
ActiveWindow.ScrollRow = 58
ActiveWindow.ScrollRow = 68
ActiveWindow.ScrollRow = 69

Range("A3:FX102").Select

ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort.SortFields.Add2 Key:= _
Range("B3:B102"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal

With ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort
.SetRange Range("A3:FX102")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply

End With
Range("C3").Select

End If

End Sub

I would like the following:

YES to be in Bold / Red
CURRENT DRIVER DATA to be in Bold / Black
DO NOT DO THIS IN THE MIDDLE OF A WEEK in Bold / Red
THIS ACTION CANNOT BE UNDONE in Bold / Red
 
Upvote 0
Last thing. I am trying to make the message window display different font colors and bold for certain information. Can someone assist?

VBA Code:
Sub SORTCURRENTDRIVERDATA()
'
If MsgBox("This is your friendly Lon-bot, reminding you that if you click YES, the CURRENT DRIVER DATA tab will be resorted into alphabetical order by driver first name. DO NOT DO THIS IN THE MIDDLE OF A WEEK, doing so may make your store data on each daily tab line up to the incorrect driver. THIS CANNOT BE UNDONE", vbYesNo) = vbYes Then
'
' SORTCURRENTDRIVERDATA Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
Range("A3").Select

ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 36
ActiveWindow.ScrollColumn = 45
ActiveWindow.ScrollColumn = 61
ActiveWindow.ScrollColumn = 75
ActiveWindow.ScrollColumn = 84
ActiveWindow.ScrollColumn = 87
ActiveWindow.ScrollColumn = 90
ActiveWindow.ScrollColumn = 95
ActiveWindow.ScrollColumn = 98
ActiveWindow.ScrollColumn = 106
ActiveWindow.ScrollColumn = 111
ActiveWindow.ScrollColumn = 117
ActiveWindow.ScrollColumn = 121
ActiveWindow.ScrollColumn = 124
ActiveWindow.ScrollColumn = 130
ActiveWindow.ScrollColumn = 132
ActiveWindow.ScrollColumn = 135
ActiveWindow.ScrollColumn = 139
ActiveWindow.ScrollColumn = 144
ActiveWindow.ScrollColumn = 150
ActiveWindow.ScrollColumn = 154
ActiveWindow.ScrollColumn = 158
ActiveWindow.ScrollColumn = 160
ActiveWindow.ScrollColumn = 162
ActiveWindow.ScrollColumn = 166
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 37
ActiveWindow.ScrollRow = 52
ActiveWindow.ScrollRow = 54
ActiveWindow.ScrollRow = 56
ActiveWindow.ScrollRow = 58
ActiveWindow.ScrollRow = 68
ActiveWindow.ScrollRow = 69

Range("A3:FX102").Select

ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort.SortFields.Add2 Key:= _
Range("B3:B102"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal

With ActiveWorkbook.Worksheets("CURRENT DRIVER DATA").Sort
.SetRange Range("A3:FX102")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply

End With
Range("C3").Select

End If

End Sub

I would like the following:

YES to be in Bold / Red
CURRENT DRIVER DATA to be in Bold / Black
DO NOT DO THIS IN THE MIDDLE OF A WEEK in Bold / Red
THIS ACTION CANNOT BE UNDONE in Bold / Red
Also, I just want to make sure before I do it, ALL the SCROLLCOLUMN and SCROLLROW can be deleted and it will not affect anything?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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