Solved

Check Boxes

Posted on 2014-02-04
6
165 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

749 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