run time error while using unprotect

acmehra

New Member
Joined
Jan 20, 2018
Messages
16
Hi Friends ,

I am trying to unprotect and worksheet from another worksheet of same file when user selects a value from dropdown combobox. System gives runtime error 5 "invalid procedure or argument "

Part of my code is :

Code:
Sub ChangeSellDataSource()
With ActiveSheet.Shapes("DD_Sell").ControlFormat
   dd_val = .List(.ListIndex)
   Sheets(dd_val).Unprotect   

  Set Data_sht = ThisWorkbook.Worksheets(dd_val) 
 Set Pivot_sht = ThisWorkbook.Worksheets("reports")

Here DD_Sell is the name of my combobox and it contains the list of named ranges. Named range text is same as that of worksheet name.
 
Last edited:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It's not clear what workbook you are working on here. You need to add the workbook to that sheets callout.

Like this:
Code:
    ThisWorkbook.Sheets(dd_val).Unprotect

Or this:
Code:
    Workbooks(workbookname).Sheets(dd_val).Unprotect

What line are you getting the error on?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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