Solved

Dropdown List Reset macro, Protect Sheet bug

Posted on 2014-10-14
2
188 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 48

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.

708 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

17 Experts available now in Live!

Get 1:1 Help Now