ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkbox control (https://www.excelbanter.com/excel-programming/319903-checkbox-control.html)

packat[_2_]

Checkbox control
 


I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.
How do I make the checkbox name dynamic so that I can do the
following:

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.chkParams???.Value = False
next i
End Sub



Thanks,
pac



Tom Ogilvy

Checkbox control
 
Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.OleObjects("chkParams" & i).Value = False
next i
End Sub

--
Regards,
Tom Ogilvy


"packat" wrote in message
news:wklBd.8300$1U6.2321@trnddc09...


I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.
How do I make the checkbox name dynamic so that I can do the
following:

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.chkParams???.Value = False
next i
End Sub



Thanks,
pac





Bob Phillips[_6_]

Checkbox control
 
Dim i As Integer
For i = 1 To 14
Sheet11.OLEObjects("chkParams" & i).Object.Value = False
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"packat" wrote in message
news:wklBd.8300$1U6.2321@trnddc09...


I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.
How do I make the checkbox name dynamic so that I can do the
following:

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.chkParams???.Value = False
next i
End Sub



Thanks,
pac





Tom Ogilvy

Checkbox control
 
Whoops, - left off the Object qualifier

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.OleObjects("chkParams" & i).Object.Value = False
next i
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.OleObjects("chkParams" & i).Value = False
next i
End Sub

--
Regards,
Tom Ogilvy


"packat" wrote in message
news:wklBd.8300$1U6.2321@trnddc09...


I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.
How do I make the checkbox name dynamic so that I can do the
following:

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.chkParams???.Value = False
next i
End Sub



Thanks,
pac







packat[_2_]

Checkbox control
 
Thanks Tom,
Works nicely.

Tom Ogilvy wrote:
Whoops, - left off the Object qualifier

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.OleObjects("chkParams" & i).Object.Value =
False
next i
End Sub


"Tom Ogilvy" wrote in message
...
Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.OleObjects("chkParams" & i).Value = False
next i
End Sub

--
Regards,
Tom Ogilvy


"packat" wrote in message
news:wklBd.8300$1U6.2321@trnddc09...


I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control
box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.
How do I make the checkbox name dynamic so that I can do
the
following:

Private Sub btnResetConst_Click()
Dim i As Integer
For i = 1 To 14
Sheet11.chkParams???.Value = False
next i
End Sub



Thanks,
pac




Don Wiss

Checkbox control
 
On Fri, 31 Dec 2004 23:32:44 GMT, "packat" wrote:

I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.


If you link each checkbox to a LinkedCell, and put the cells together and
assign them a range name, you can do it without a loop:

Range("CheckBoxCells").Value = False

Don <donwiss at panix.com.

packat[_2_]

Checkbox control
 

Thanks Don. The ocde is now even tighter! I did try that
before posting the question, but it did't work. Come to
think of it, perhaps the control was in edit mode :-)
pax


Don Wiss wrote:
On Fri, 31 Dec 2004 23:32:44 GMT, "packat"

wrote:

I have 10 checkboxes with names chkParams1,
chkParams2,...,chkParams10.

I am writing a sub to reset these boxes using a control
box.
I could simply put the statement:
Sheet11.chkParams1.Value = False .....

for all of the boxes. But I am wondering if there is a
better way using a for loop.


If you link each checkbox to a LinkedCell, and put the
cells together
and assign them a range name, you can do it without a
loop:

Range("CheckBoxCells").Value = False

Don <donwiss at panix.com.





All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com