Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default VBA to Make Check Box Entry

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA to Make Check Box Entry

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default VBA to Make Check Box Entry

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default VBA to Make Check Box Entry

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA to Make Check Box Entry

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default VBA to Make Check Box Entry

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
make a check form, and then have info go to a check register richie g Excel Worksheet Functions 0 May 5th 10 12:10 AM
How do I make the check mark boc bigger on the check box? srod Excel Discussion (Misc queries) 0 October 6th 08 09:52 PM
check for previous entry MichaelCasper New Users to Excel 2 August 29th 08 11:36 PM
Entry into check box dependent on other check box. Stilla Excel Worksheet Functions 9 December 10th 05 03:44 PM
Menu entry with check? Tom Excel Programming 1 August 23rd 03 06:21 PM


All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"