+ Reply to Thread
Results 1 to 2 of 2

CHECK BOX Code use twice in different column

  1. #1
    Registered User
    Join Date
    08-23-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2011 MAC
    Posts
    1

    CHECK BOX Code use twice in different column

    Hi there,

    I'm editing a worksheet that has VB Code for check boxes: the code is this:

    Sub AddCheckBox()
    Dim cell As Range

    DelCheckBox 'Do the delete macro
    'or delete all checkboxes in the worksheet
    ' ActiveSheet.CheckBoxes.Delete

    For Each cell In Range("A5:A200")
    With ActiveSheet.CheckBoxes.Add(cell.Left, _
    cell.Top, cell.Width, cell.Height)
    .LinkedCell = cell.Offset(, 1).Address(External:=True)
    .Interior.ColorIndex = 37 'or xlNone or xlAutomatic
    .Caption = ""
    .Border.Weight = xlThin
    End With
    Next

    With Range("A5:A200")
    .Rows.RowHeight = 15
    End With
    End Sub


    Sub DelCheckBox()
    For Each cell In Range("A5:A200")
    Worksheets("Sheet1").CheckBoxes.Delete
    Next
    End Sub


    I have this running in Column A and column B returning the value

    I would like to duplicate this process for Columns D & E to create a second set of check boxes however when I try to duplicate the macro (editing the columns from A to D) and run it it merely moves the original check boxes from A to D in the worksheet..

    I'm generally good with excel and understand the basics of VB but I'm stumped with this one.. anyone able to help me out with this?

    Appreciated

    Scar

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: CHECK BOX Code use twice in different column

    Welcome to the forum, scar.

    Please would you edit your post and put code tags around your code? See how in my signature.
    Hope that helps,

    Colin

    RAD Excel Blog

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1