Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Linking Cells

I have a macro written where once you check a box it paste's a set
word into cells on other sheets. I have those other sheets locked so
that no one can edit them. The macro works when the cells are not
protected but does not work when the cells are protected. Does anyone
know a way around this? This is the code i have for the checkboxes.

'Checkbox code
With CheckBox1
If .Value = True Then
Worksheets("RENOVATION").Range("B6:E6").Value = "Leased"
Worksheets("BASE BUILDING").Range("B6:E6").Value =
"Leased"
Else
Worksheets("RENOVATION").Range("B6:E6").ClearConte nts
Worksheets("BASE BUILDING").Range("B6:E6").ClearContents
End If
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Linking Cells

Try this:
'Checkbox code
ActiveSheet.Unprotect
With CheckBox1
If .Value = True Then
Worksheets("RENOVATION").Range("B6:E6").Value = "Leased"
Worksheets("BASE BUILDING").Range("B6:E6").Value =
"Leased"
Else
Worksheets("RENOVATION").Range("B6:E6").ClearConte nts
Worksheets("BASE BUILDING").Range("B6:E6").ClearContents
End If
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




" wrote:

I have a macro written where once you check a box it paste's a set
word into cells on other sheets. I have those other sheets locked so
that no one can edit them. The macro works when the cells are not
protected but does not work when the cells are protected. Does anyone
know a way around this? This is the code i have for the checkboxes.

'Checkbox code
With CheckBox1
If .Value = True Then
Worksheets("RENOVATION").Range("B6:E6").Value = "Leased"
Worksheets("BASE BUILDING").Range("B6:E6").Value =
"Leased"
Else
Worksheets("RENOVATION").Range("B6:E6").ClearConte nts
Worksheets("BASE BUILDING").Range("B6:E6").ClearContents
End If
End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Linking Cells

I'd try something like this

Sub test2()
'Checkbox code

Call CheckBoxCheck("Renovation", CheckBox1)
Call CheckBoxCheck("Base Building", CheckBox1)

End Sub
Sub CheckBoxCheck(myWSName As String, myCheckBox As Variant)
Dim Protection As Boolean

Dim myWS As Worksheet
Set myWS = Nothing
On Error Resume Next
Set myWS = Worksheets(myWSName)
On Error GoTo 0
If myWS Is Nothing Then
MsgBox ("Worksheet " & myWSName & " does not exist in the active
workbook")
Exit Sub
End If

If myWS.ProtectionMode = True Then
Protection = True
myWS.Unprotect
If myCheckBox.Value Then
myWS.Range("B6:E6").Value = "Leased"
Else
myWS.Range("B6:E6").ClearContents
End If
End If
If Protection Then
myWS.Protect
End If

End Sub

--
HTH,
Barb Reinhardt



" wrote:

I have a macro written where once you check a box it paste's a set
word into cells on other sheets. I have those other sheets locked so
that no one can edit them. The macro works when the cells are not
protected but does not work when the cells are protected. Does anyone
know a way around this? This is the code i have for the checkboxes.

'Checkbox code
With CheckBox1
If .Value = True Then
Worksheets("RENOVATION").Range("B6:E6").Value = "Leased"
Worksheets("BASE BUILDING").Range("B6:E6").Value =
"Leased"
Else
Worksheets("RENOVATION").Range("B6:E6").ClearConte nts
Worksheets("BASE BUILDING").Range("B6:E6").ClearContents
End If
End With


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking cells again :-( pegman Excel Discussion (Misc queries) 7 December 31st 07 09:46 PM
Linking cells into empty cells in another worksheet Bookworm Excel Discussion (Misc queries) 6 October 14th 07 11:11 AM
Linking cells with a diffrent sheet with 2 cells Angelofdoom Excel Worksheet Functions 2 February 15th 06 04:20 PM
Linking many cells dk Excel Discussion (Misc queries) 2 October 28th 05 04:16 PM
Linking a horizontal set of cells to a vertical sets of cells Russell-stanely Charts and Charting in Excel 2 October 21st 05 03:19 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"