Solved

Check Boxes

Posted on 2014-02-04
6
161 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
  • 3
  • 2
6 Comments
 
LVL 26

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 26

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now