?
Solved

Dropdown List Reset macro, Protect Sheet bug

Posted on 2014-10-14
2
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Viewers will learn a basic data manipulation technique of unpivoting data in Power Query for Excel 2013 and the importance of using good data. Start with data in a poor structure: Create a table on your data: Unpivot columns: Rename columns: …
Video by: Zack
Viewers will learn the basics of using Excel Tables, the benefits found with them, and some pitfalls.

777 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