lock - Hide - and Font color change macro

rmb_77

New Member
Joined
Aug 11, 2010
Messages
7
Goodafternoon to all

i humbly request help on the folling problem i have with a macro i am trying to get to work.

the macro is linked to a check box and is meant to do the following:

when checked:
1.lock a range of cells on the active sheet ("this works for me")
2.change the font color for a certain range on the active sheet ("works too).
3.Select another sheet and hide a row on that sheet , then return to the active sheet ("this i cant get to work..:(((

When unchecked:
1.Unlock a range of cells on the active sheet ("this works for me")
2.change the font color back which also works
3.select the other sheet and unhide the row again , after this return to the active sheet (im stuck here)

is it possible to ad 3 different actions to a checkbox??

this is my code so far"

Private Sub CheckBox1_Click()
Sheet30.Unprotect Password:="xxxx"
Range("A11:K11").Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Dim StartCell As Range
Set StartCell = ActiveCell
Range("H11").Select
If CheckBox1.Value = True Then
Selection.Locked = True
Else
Selection.Locked = False
Range("A11:K11").Select
With Selection.Font
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
End With
End If
StartCell.Activate
Set StartCell = Nothing
Sheet30.Protect Password:="xxxx"
End Sub


i really hope someone can help me with this issue...

many thanks in advance!!

Mike
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
As an example, this will hide row 5 on Sheet3

Code:
Sheets("Sheet3").Rows(5).Hidden = True

Use the same code but set it to False to unhide it.

You don't need to "Select" a sheet or range of cells to do something to them. This will Hide\Unhide that row without leaving your current sheet.
 
Upvote 0
Hey AlphaFrog

that looks like the best option yes indeed

however when i insert it in my code i get the following error..

Run-time error '9':
Subscript out of range

could it be in the wrong section of the code??

anything you can help with ??

many thanks in advance..
 
Upvote 0
Hey Alpha Frog

it works like a charm , my bad!!

thank you very much for your help!!

greetz

Mike
 
Upvote 0
Did you change the name of the sheet? If yes, then is it exactly the same name of the actual sheet?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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