Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a check box on a worksheet that was set up using the Toolbox toolbar.
As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Option Explicit
Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .CheckBox1.Value = True Else .CheckBox1.Value = False End If End With End Sub You'll have to know the name of that checkbox in A2. For me, it was named Checkbox1. Ken Hudson wrote: I have a check box on a worksheet that was set up using the Toolbox toolbar. As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great - thanks Dave.
-- Ken Hudson "Dave Peterson" wrote: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .CheckBox1.Value = True Else .CheckBox1.Value = False End If End With End Sub You'll have to know the name of that checkbox in A2. For me, it was named Checkbox1. Ken Hudson wrote: I have a check box on a worksheet that was set up using the Toolbox toolbar. As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dave,
Well, I replied too quickly. This workbook was inherited and I thought the check boxes were created using the Tool Box tool bar. In fact, they were created using the Forms tool bar. When I right click on one check box on the form, I see that it is named Check Box 1. But I haven't been able to figure out how to get a check mark in it with VBA. What is the way to reference a check box form in my VBA? TIA. -- Ken Hudson "Dave Peterson" wrote: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .CheckBox1.Value = True Else .CheckBox1.Value = False End If End With End Sub You'll have to know the name of that checkbox in A2. For me, it was named Checkbox1. Ken Hudson wrote: I have a check box on a worksheet that was set up using the Toolbox toolbar. As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For the most part, I think that the controls from the Forms toolbar are easier
to work with: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .checkboxes("Check box 1").value = xlon Else .checkboxes("Check box 1").value = xloff End If End With End Sub You can actually do it in one line: with worksheets("sheet1") .checkboxes("Check box 1").value = cbool(.range("a1").value = 45) end with but sometimes seeing the if/then/else makes things easier to understand. Ken Hudson wrote: Hi Dave, Well, I replied too quickly. This workbook was inherited and I thought the check boxes were created using the Tool Box tool bar. In fact, they were created using the Forms tool bar. When I right click on one check box on the form, I see that it is named Check Box 1. But I haven't been able to figure out how to get a check mark in it with VBA. What is the way to reference a check box form in my VBA? TIA. -- Ken Hudson "Dave Peterson" wrote: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .CheckBox1.Value = True Else .CheckBox1.Value = False End If End With End Sub You'll have to know the name of that checkbox in A2. For me, it was named Checkbox1. Ken Hudson wrote: I have a check box on a worksheet that was set up using the Toolbox toolbar. As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson -- Dave Peterson -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks again, Dave!
-- Ken Hudson "Dave Peterson" wrote: For the most part, I think that the controls from the Forms toolbar are easier to work with: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .checkboxes("Check box 1").value = xlon Else .checkboxes("Check box 1").value = xloff End If End With End Sub You can actually do it in one line: with worksheets("sheet1") .checkboxes("Check box 1").value = cbool(.range("a1").value = 45) end with but sometimes seeing the if/then/else makes things easier to understand. Ken Hudson wrote: Hi Dave, Well, I replied too quickly. This workbook was inherited and I thought the check boxes were created using the Tool Box tool bar. In fact, they were created using the Forms tool bar. When I right click on one check box on the form, I see that it is named Check Box 1. But I haven't been able to figure out how to get a check mark in it with VBA. What is the way to reference a check box form in my VBA? TIA. -- Ken Hudson "Dave Peterson" wrote: Option Explicit Sub testme() With Worksheets("Sheet1") If .Range("A1").Value = 45 Then .CheckBox1.Value = True Else .CheckBox1.Value = False End If End With End Sub You'll have to know the name of that checkbox in A2. For me, it was named Checkbox1. Ken Hudson wrote: I have a check box on a worksheet that was set up using the Toolbox toolbar. As part of a VBA routine I want to put a check into that box as part of a looping routine. If Range("A1")=45 then .....code here to put a check into A2 End If Record a macro wasn't any help. What is the code to do this, please? TIA. -- Ken Hudson -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
make a check form, and then have info go to a check register | Excel Worksheet Functions | |||
How do I make the check mark boc bigger on the check box? | Excel Discussion (Misc queries) | |||
check for previous entry | New Users to Excel | |||
Entry into check box dependent on other check box. | Excel Worksheet Functions | |||
Menu entry with check? | Excel Programming |