Run-time error '1004' for a scroll bar (form control)

mdfahiem

New Member
Joined
Oct 10, 2017
Messages
6
Hi Gurus,

I have a scroll bar (form control). There are cells which are updated based on the scroll bar value.

I want to protect the work sheet and I have selected the cells to be protected and have them Locked in format cells --> Protection.

When I scroll to next level, below message is shown:
Microsoft Visual Basic
Run-time error '1004'
Unable to set the Hidden property of the Range class

And there are 3 options: End, Debug and Help

Below is the code:
Sub showcalendar()
LeaveTracker.Columns("B:NI").Hidden = True This is highlighted with yellow color
LeaveTracker.Range(Columns(Range("A3").Value * 31 - 29), Columns(Range("A3").Value * 31 + 1)).Hidden = False
End Sub

I am quite new to the coding.

Please guide me what might be wrong.

Thanks in advance.

Regards,
Fahim
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I found the solution, changed the code as below:


Sub showcalendar()
ActiveSheet.Unprotect
LeaveTracker.Columns("B:NI").Hidden = True
LeaveTracker.Range(Columns(Range("A3").Value * 31 - 29), Columns(Range("A3").Value * 31 + 1)).Hidden = False
ActiveSheet.Protect
End Sub

Regards,
Fahim
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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