+ Reply to Thread
Results 1 to 4 of 4

How do I chane the properties of a CheckBox using VBA?

  1. #1
    Registered User
    Join Date
    07-31-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    7

    How do I chane the properties of a CheckBox using VBA?

    Hi,

    I am trying to use VBA to change the caption of checkboxes in "Sheet 2" when I change the value of a cell "A1" in "Sheet 1".
    This code is working:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, ActiveSheet.Range("A1")) Is Nothing Then Exit Sub
    Worksheets("Sheet 2").CheckBox1.Caption = "New Caption"
    End Sub

    But there are 6 checkboxes in Sheet 2 and I would like to do something like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, ActiveSheet.Range("A1")) Is Nothing Then Exit Sub
    For i = 0 to 5
    Worksheets("Sheet 2").Control("CheckBox" & i+1).Caption = "Box" & i+1
    Next i
    End Sub

    This doesn't work.. So I guess the Control-function is wrong. Any suggestions on what I should do?

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How do I chane the properties of a CheckBox using VBA?

    *untested*

    change
    Worksheets("Sheet 2").Control("CheckBox" & i+1).Caption = "Box" & i+1

    to

    Please Login or Register  to view this content.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    07-31-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    7

    Re: How do I chane the properties of a CheckBox using VBA?

    YES! It worked! Thanks!

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How do I chane the properties of a CheckBox using VBA?

    not a problem
    if you are happy with solution please mark thread solved

    Cheers
    Hum

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add Code to properties in active x CheckBox
    By chriswhite1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2013, 12:13 PM
  2. Project Properties Checkbox
    By JSMITHXX in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 08:51 PM
  3. [SOLVED] VBA to chane worksheet tab color
    By bmcglone in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 11:39 AM
  4. Have checkbox change properties of spin button (form control)
    By spookymyo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-19-2013, 04:19 AM
  5. checkbox name/properties
    By miso.dca in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2009, 02:45 PM

Tags for this Thread

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