[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Checkbox fires off a Statement

Posted on 2016-11-16
7
Medium Priority
?
48 Views
Last Modified: 2016-11-16
EE Pros,

I've attached a Workbook where WS1 has a "checkbox".  My macro for on/off is not working and needs a tweek.  What I'm trying to do is when the checkbox is "checked", it will auto populate specified Worksheets within my Workbook with the word "Confidential".  I can adjust the Macro to choose the appropriate cell to populate, but don't know how to write the Macro to get it started/done.

Much thanks in advance.

B.
Checkbox.xlsm
0
Comment
Question by:Bright01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41889681
Hi,

pls try

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Provides check button
If Not Intersect(Target, [C4]) Is Nothing Then
'If Target.Column = 3 Then
    Application.ScreenUpdating = False
  
    With Target
        If .Value = "P" Then
            .Value = ""
        ElseIf .Value = "" Then
            .Font.Name = "Wingdings 2"
            .Value = "P"
        End If
   End With
   End If
    Cancel = True
    Application.ScreenUpdating = True
End Sub

Open in new window

Regards
0
 

Author Comment

by:Bright01
ID: 41889962
Regonzo,

Greetings!  Thanks for picking this up.  The first half of my "ask"?  You nailed it.  Thank you.

The second half is an addition to the Macro that allows text to be placed in a specified cell on the other Sheets  (Sheet needs to be named and cell where text is going).

So..... if the cell on Sheet 1 is "checked", the text is auto placed on the other sheets listed in the Macro + the specific cell on that sheet.  In this case, it will say "confidential" on the other sheets if the box is checked.

Thank you,


B.
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41890104
then try
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Provides check button
strSheets = "Sheet2,Sheet3"
strCellAddress = "B5"
If Not Intersect(Target, [C4]) Is Nothing Then
    Application.ScreenUpdating = False
  
    With Target
        If .Value = "P" Then
            .Value = ""
            For Each strSheet In Split(strSheets, ",")
                Sheets(strSheet).Range(strCellAdress).Value = ""
            Next
        ElseIf .Value = "" Then
            .Font.Name = "Wingdings 2"
            .Value = "P"
            For Each strSheet In Split(strSheets, ",")
                Sheets(strSheet).Range(strCellAdress).Value = "Confidential"
            Next
        End If
    End With
End If
Cancel = True
Application.ScreenUpdating = True
End Sub

Open in new window

Edited code
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Bright01
ID: 41890120
Regonzo,

I get an error;

strSheets is not defined........

strSheets = "Sheet2,Sheet3"
0
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 41890126
then try
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Provides check button
Dim strSheet As Variant, strSheets As String
Dim strCellAddress As String
strSheets = "Sheet2,Sheet3"
strCellAddress = "B5"
If Not Intersect(target, [C4]) Is Nothing Then
    Application.ScreenUpdating = False
  
    With target
        If .Value = "P" Then
            .Value = ""
            For Each strSheet In Split(strSheets, ",")
                Sheets(strSheet).Range(strCellAddress).Value = ""
            Next
        ElseIf .Value = "" Then
            .Font.Name = "Wingdings 2"
            .Value = "P"
            For Each strSheet In Split(strSheets, ",")
                Sheets(strSheet).Range(strCellAddress).Value = "Confidential"
            Next
        End If
    End With
End If
Cancel = True
Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:Bright01
ID: 41890240
Regonzo,

Almost.  I tested it and it almost works.  Here are two questions;

1.) If I want the "confidential" text to show up on Sheets 2 and 3, but want it to show up and disappear (depending on the status of the checkmark -- on/off) how do I distinguish between the cells?  Right now, it shows up at the same sell on each Sheet.

2.) If I want to simply say "all sheets" so as not to have to identify each individual sheet, what line of code would I use to substitute where it tells which sheets to place the text?

Thank you,

B.
0
 

Author Closing Comment

by:Bright01
ID: 41890595
Rgonzo, Great Job!!!  Thank you very much!  Appreciate your help.  I'm going to post another request for the two additional enhancements to the macro.  You did a great job.  No scope creep here ;-)

Be good and again, much thanks,

B.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

649 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