Solved

Check Boxes

Posted on 2014-02-04
6
168 Views
Last Modified: 2014-02-04
EE Pros,

I had an EE Pro build out a small macro that when you double clicked, it put a check in a box.

I've now tried to adapt it to a "row" instead of a column and cannot get it to work right.  I think it may have something to do with the "offsets".   I would appreciate some help in getting this to work correctly.

Thank you in advance,

B.
Check-Boxes.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
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39832387
Not sure exactly how you want it adapted.

In any case the first parameter of Offset is the RowOffset and the second one is the ColumnOffset.

I assume you want something like this:
    With ActiveCell
        If .Value = "P" Then
            .Value = ""
            .Offset(4, 0).ClearContents
        ElseIf .Offset(1, 0).Value <> "" Then
            .Font.Name = "Wingdings 2"
            .Value = "P"
            .Offset(4, 0).FormulaR1C1 = ""            '"=Value"    'Value is not a defined name
        End If
    End With

Open in new window

0
 

Author Comment

by:Bright01
ID: 39832423
MacroShadow,

I changed the code to match what you sent me but it still doesn't work.

Just to be clear, when you open the sample WB/WS, and you double click on cells in Row 15, it automatically should put a "checkmark" in the box (which is capital "P" and Wingdings2).

That's what I'm trying to get working......

b.
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39832507
Option Explicit
Sub insertCheckboxes()
 
  Dim myBox As CheckBox
  Dim myCell As Range
 
  Dim cellRange As String
  Dim cboxLabel As String
  Dim linkedColumn As String
 
  cellRange = InputBox(Prompt:="Cell Range", _
    Title:="Cell Range")
 
  linkedColumn = InputBox(Prompt:="Linked Column", _
    Title:="Linked Column")
 
  cboxLabel = InputBox(Prompt:="Checkbox Label", _
    Title:="Checkbox Label")
 
  With ActiveSheet
    For Each myCell In .Range(cellRange).Cells
      With myCell
        Set myBox = .Parent.CheckBoxes.Add(Top:=.Top, _
          Width:=.Width, Left:=.Left, Height:=.Height)
 
        With myBox
          .LinkedCell = linkedColumn & myCell.Row
          .Caption = cboxLabel
          .Name = "checkbox_" & myCell.Address(0, 0)
        End With
 
        .NumberFormat = ";;;"
      End With
 
    Next myCell
  End With
End Sub
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:Bright01
ID: 39832590
Esskay,

I tried this code and unfortunately it doesn't work.  

Can you open my workbook and see what I'm trying to accomplish?  If you double click on the cells in row 15, it should automatically place a "P" that then converts to a check mark.

B.
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39832644
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Provides check button
    If Target.Row = 15 Then
        Application.ScreenUpdating = False
        With ActiveCell
            If .Value = "P" Then
                .Value = ""
            Else
                .Font.Name = "Wingdings 2"
                .Value = "P"
            End If
        End With
        'These two lines below make it a realtime update
        Cancel = True
        Application.ScreenUpdating = True
    End If
End Sub

Open in new window

0
 

Author Closing Comment

by:Bright01
ID: 39832681
Perfect!  Thank you!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

617 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