Help in updating a checkbox macro

AusSteelMan

Board Regular
Joined
Sep 4, 2009
Messages
208
Hi everyone,

I would like some help on this modification I'd like to make.

Background:
I'm running a footy tipping comp with some friends and family. I'd like to use checkboxes to aid the speed of entry. I have the following code that inserts checkboxes into a specified range.


Code:
Sub insertCheckboxes_InRows_OnCentre()
'Found via Chandoo.org at:
'http://www.terminally-incoherent.com/blog/2008/09/04/excel-adding-checkboxes-the-easy-way/
 
'modified to position the checkbox close to on centre horizontally of the cell
'with a width of 35 pixels and height of 17 pixels (standard height)
 
'modified to insert in ROWs not COLUMNs
 
 
  Dim myBox As CheckBox
  Dim myCell As Range
 
  Dim cellRange As String
  Dim cboxLabel As String
  Dim linkedRow As Integer
 
  cellRange = InputBox(Prompt:="Cell Range", _
    Title:="Cell Range")
 
  linkedRow = InputBox(Prompt:="Linked Row", _
    Title:="Linked Row")
 
  '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 - (.Height / 6), _
            Width:=.Width, Left:=.Left + (.Width / 5.5), Height:=.Height / 4)
 
        With myBox
          .LinkedCell = Cells(linkedRow, myCell.Column).Address
         ' .Caption = cboxLabel
          .Name = "checkbox_" & myCell.Address(0, 0)
        End With
 
        .NumberFormat = ";;;"
      End With
 
    Next myCell
  End With
End Sub

The mod I'd like to make is to basically remove the user entry options. The checkboxes cellRange should be columns D to S in the currently selected row. Thus, the linkedRow is also the current row.
There is no caption (hence the commenting out of the relevant lines of code).
I started to look at this a couple of weeks ago, but had some urgent real work to do and have not had a chance to get back to this task and the footy starts this weekend.

Any help is much appreciated.

Thanks,
Darren
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
First comment out the other user input VBA rows. Then make your loop start like this:
Code:
   For Each myCell In .Range("D" & ActiveCell.Row & ":S" & ActiveCell.Row).Cells
and change the linkedcell part to be
Code:
.LinkedCell = myCell.Address
 
Upvote 0
Thanks very Glenn. I'm sure I had been close and of course what you did is now oblivious, but I just wasn't good enough to get it. I appreciate your help very much.

Darren
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top