Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Importing Checkbox Values

Hello:

I have 20 checkboxes on a worksheet (called
PriorVersion.xls"), some of which may be checked, some
may not. I want to duplicate the checked checkboxes onto
another sheet (containing 20 identical checkboxes) using
code. Both sheets are called "Instructions", and are in
two separate workbooks.

I want to set up a For-Next loop to examine each checkbox
(1-20) in the original worksheet and make the counterpart
of each in the new workbook the same "Value" (True or
False, e.g. automatically check boxes 5, 8, 12 and 15 in
the new workbook if the same boxes are checked in the old
workbook).

The code below doesn't work because the syntax is wrong
(it doesn't like statement inside my For loop - "object
doesn't support this property or method").

Dim OLDINST, NEWINST as Object
Set OLDINST = Workbooks("PriorVersion.xls").Sheets
("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name).Sheets
("Instructions")
For BOX = 1 To 20
NEWINST.CheckboxBOX.Value = OLDINST.CheckboxBOX.Value
Next BOX

I could do it with 20 If-Then statements, but there has
to be a way to use the checkbox number as a variable.

One condition: the checkboxes in the new workbook call
macros when they are clicked. I DO NOT want this code to
execute when the values of the checkboxes are imported
from the previous workbook. I'm thinking this will be
the case (i.e., the code will not execute unless the
boxes are clicked, but I can change the values without
clicking the boxes).

Any ideas? Help is appreciated.
Thanks, MARTY
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Importing Checkbox Values

For i = 1 To Worksheets("OLDINST").Checkboxes.Count
Worksheets("NEWINST").Checkboxes(i).Value = _
Worksheets("OLDINST").Checkboxes(i).Value
Next i



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Marty" wrote in message
...
Hello:

I have 20 checkboxes on a worksheet (called
PriorVersion.xls"), some of which may be checked, some
may not. I want to duplicate the checked checkboxes onto
another sheet (containing 20 identical checkboxes) using
code. Both sheets are called "Instructions", and are in
two separate workbooks.

I want to set up a For-Next loop to examine each checkbox
(1-20) in the original worksheet and make the counterpart
of each in the new workbook the same "Value" (True or
False, e.g. automatically check boxes 5, 8, 12 and 15 in
the new workbook if the same boxes are checked in the old
workbook).

The code below doesn't work because the syntax is wrong
(it doesn't like statement inside my For loop - "object
doesn't support this property or method").

Dim OLDINST, NEWINST as Object
Set OLDINST = Workbooks("PriorVersion.xls").Sheets
("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name).Sheets
("Instructions")
For BOX = 1 To 20
NEWINST.CheckboxBOX.Value = OLDINST.CheckboxBOX.Value
Next BOX

I could do it with 20 If-Then statements, but there has
to be a way to use the checkbox number as a variable.

One condition: the checkboxes in the new workbook call
macros when they are clicked. I DO NOT want this code to
execute when the values of the checkboxes are imported
from the previous workbook. I'm thinking this will be
the case (i.e., the code will not execute unless the
boxes are clicked, but I can change the values without
clicking the boxes).

Any ideas? Help is appreciated.
Thanks, MARTY



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Importing Checkbox Values

This one works as well.

Thanks, Bob!

-----Original Message-----
For i = 1 To Worksheets("OLDINST").Checkboxes.Count
Worksheets("NEWINST").Checkboxes(i).Value = _
Worksheets("OLDINST").Checkboxes(i).Value
Next i



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Marty" wrote in

message
...
Hello:

I have 20 checkboxes on a worksheet (called
PriorVersion.xls"), some of which may be checked, some
may not. I want to duplicate the checked checkboxes

onto
another sheet (containing 20 identical checkboxes)

using
code. Both sheets are called "Instructions", and are

in
two separate workbooks.

I want to set up a For-Next loop to examine each

checkbox
(1-20) in the original worksheet and make the

counterpart
of each in the new workbook the same "Value" (True or
False, e.g. automatically check boxes 5, 8, 12 and 15

in
the new workbook if the same boxes are checked in the

old
workbook).

The code below doesn't work because the syntax is wrong
(it doesn't like statement inside my For loop - "object
doesn't support this property or method").

Dim OLDINST, NEWINST as Object
Set OLDINST = Workbooks("PriorVersion.xls").Sheets
("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name).Sheets
("Instructions")
For BOX = 1 To 20
NEWINST.CheckboxBOX.Value = OLDINST.CheckboxBOX.Value
Next BOX

I could do it with 20 If-Then statements, but there has
to be a way to use the checkbox number as a variable.

One condition: the checkboxes in the new workbook call
macros when they are clicked. I DO NOT want this code

to
execute when the values of the checkboxes are imported
from the previous workbook. I'm thinking this will be
the case (i.e., the code will not execute unless the
boxes are clicked, but I can change the values without
clicking the boxes).

Any ideas? Help is appreciated.
Thanks, MARTY



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing Checkbox Values

Dim OLDINST as worksheet, NEWINST as worksheet
Set OLDINST = Workbooks("PriorVersion.xls"). _
Sheets("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name). _
Sheets("Instructions")
For BOX = 1 To 20
NEWINST.OleObjects("Checkbox" & Box).Object.Value = _
OLDINST.OleObjects("Checkbox" & Box).Object.Value
Next BOX


This assumes the checkboxes are from the control toolbox toolbar. If from
the forms toolbar, the code would be different.

Also, I believe changing the value will trigger the event. If so, you would
need to have the event code check something and exit immediately if the
condition were met. You could then have the above code set the condition to
exit.

--
Regards,
Tom Ogilvy




"Marty" wrote in message
...
Hello:

I have 20 checkboxes on a worksheet (called
PriorVersion.xls"), some of which may be checked, some
may not. I want to duplicate the checked checkboxes onto
another sheet (containing 20 identical checkboxes) using
code. Both sheets are called "Instructions", and are in
two separate workbooks.

I want to set up a For-Next loop to examine each checkbox
(1-20) in the original worksheet and make the counterpart
of each in the new workbook the same "Value" (True or
False, e.g. automatically check boxes 5, 8, 12 and 15 in
the new workbook if the same boxes are checked in the old
workbook).

The code below doesn't work because the syntax is wrong
(it doesn't like statement inside my For loop - "object
doesn't support this property or method").

Dim OLDINST, NEWINST as Object
Set OLDINST = Workbooks("PriorVersion.xls").Sheets
("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name).Sheets
("Instructions")
For BOX = 1 To 20
NEWINST.CheckboxBOX.Value = OLDINST.CheckboxBOX.Value
Next BOX

I could do it with 20 If-Then statements, but there has
to be a way to use the checkbox number as a variable.

One condition: the checkboxes in the new workbook call
macros when they are clicked. I DO NOT want this code to
execute when the values of the checkboxes are imported
from the previous workbook. I'm thinking this will be
the case (i.e., the code will not execute unless the
boxes are clicked, but I can change the values without
clicking the boxes).

Any ideas? Help is appreciated.
Thanks, MARTY



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Importing Checkbox Values

Worked like a charm. Thanks Tom!
I don't yet know if it activates the code for the
checkboxes. I'll work on that later, but for now, the
values match. Thanks again!

-----Original Message-----
Dim OLDINST as worksheet, NEWINST as worksheet
Set OLDINST = Workbooks("PriorVersion.xls"). _
Sheets("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name). _
Sheets("Instructions")
For BOX = 1 To 20
NEWINST.OleObjects("Checkbox" & Box).Object.Value = _
OLDINST.OleObjects("Checkbox" & Box).Object.Value
Next BOX


This assumes the checkboxes are from the control toolbox

toolbar. If from
the forms toolbar, the code would be different.

Also, I believe changing the value will trigger the

event. If so, you would
need to have the event code check something and exit

immediately if the
condition were met. You could then have the above code

set the condition to
exit.

--
Regards,
Tom Ogilvy




"Marty" wrote in

message
...
Hello:

I have 20 checkboxes on a worksheet (called
PriorVersion.xls"), some of which may be checked, some
may not. I want to duplicate the checked checkboxes

onto
another sheet (containing 20 identical checkboxes)

using
code. Both sheets are called "Instructions", and are

in
two separate workbooks.

I want to set up a For-Next loop to examine each

checkbox
(1-20) in the original worksheet and make the

counterpart
of each in the new workbook the same "Value" (True or
False, e.g. automatically check boxes 5, 8, 12 and 15

in
the new workbook if the same boxes are checked in the

old
workbook).

The code below doesn't work because the syntax is wrong
(it doesn't like statement inside my For loop - "object
doesn't support this property or method").

Dim OLDINST, NEWINST as Object
Set OLDINST = Workbooks("PriorVersion.xls").Sheets
("Instructions")
Set NEWINST = Workbooks(ActiveWorkbook.Name).Sheets
("Instructions")
For BOX = 1 To 20
NEWINST.CheckboxBOX.Value = OLDINST.CheckboxBOX.Value
Next BOX

I could do it with 20 If-Then statements, but there has
to be a way to use the checkbox number as a variable.

One condition: the checkboxes in the new workbook call
macros when they are clicked. I DO NOT want this code

to
execute when the values of the checkboxes are imported
from the previous workbook. I'm thinking this will be
the case (i.e., the code will not execute unless the
boxes are clicked, but I can change the values without
clicking the boxes).

Any ideas? Help is appreciated.
Thanks, MARTY



.



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
importing multiple values from a spreadsheet Perplexed Peter Excel Worksheet Functions 2 May 29th 08 12:05 AM
Checkbox values? T135 Excel Worksheet Functions 2 January 12th 07 10:46 AM
Importing checkbox data from web page Linda Ellison Excel Discussion (Misc queries) 0 April 18th 06 06:46 PM
CheckBox values Allan[_4_] Excel Programming 1 December 22nd 03 05:02 PM
Checkbox values from a web client Larry[_10_] Excel Programming 1 September 11th 03 06:45 PM


All times are GMT +1. The time now is 09:44 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"