Solved

Dropdown List Reset macro, Protect Sheet bug

Posted on 2014-10-14
2
192 Views
Last Modified: 2014-10-15
Hi, the macro below has been working fine to reset a number or dropdowns I have on a spreadsheet, but if I Protect the worksheet I get the following error: Runtime error '424' - Object Required

How can I modify this macro to run when I Protect the worksheet?

Many thanks in advance!


Sub ResetList()
'
' ResetList Macro
'
Dim rngList As Range
Dim ListCell As Range

On Error Resume Next
Set rngLists = Sheets("AP Risk Scorecard").UsedRange.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0

If Not rngLists Is Nothing Then
For Each ListCell In rngLists.Cells
ListCell.Value = Range(Trim(Mid(Replace(ListCell.Validation.Formula1, ":", String(99, " ")), 2, 99))).Value
Next ListCell
End If
Range("E15").Select

End Sub

Open in new window

0
Comment
Question by:scsnow2310
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40381511
Hi,

pls try

Sub ResetList()
'
' ResetList Macro
'
Dim rngList As Range
Dim ListCell As Range
Dim pw As String
pw = "myPW"
Sheets("AP Risk Scorecard").Unprotect pw
On Error Resume Next
Set rngLists = Sheets("AP Risk Scorecard").UsedRange.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0

If Not rngLists Is Nothing Then
For Each ListCell In rngLists.Cells
ListCell.Value = Range(Trim(Mid(Replace(ListCell.Validation.Formula1, ":", String(99, " ")), 2, 99))).Value
Next ListCell
End If
Range("E15").Select
Sheets("AP Risk Scorecard").Protect pw


End Sub

Open in new window


Change pw to your needs

Regards
0
 

Author Closing Comment

by:scsnow2310
ID: 40383125
Perfect!

Many thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Viewers will learn what comprises a theme in Excel 2013, as well as how to customize them.
Viewers will learn the basics of the new Quick Analysis feature in Excel 2013.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now