View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Method 'Range' of Object_Worksheet Failed

No, your explanation doesn't make much sense.

If you loop over 29 checkboxes and each time you find one that is true, you
loop over the same five checkboxes and change the values on five associated
ranges based on the value of the checkbox, either you will change the same
cells to the same value between 1 and 29 times or not at all. But if that
is what you want to do, then just clean up the pseudo code you show
For i = 1 To 29
If WS2.OLEObjects("CheckBoxSpecies" & i).Object.Value = True Then
IF ws1.OleObjects("CheckBoxBedrockL1") _
.Value = False then rng1 = "NA"
IF ws1.OleObjects("CheckBoxBedrockL2") _
.Value = False then rng2 = "NA"
IF ws1.OleObjects("CheckBoxBedrockL3") _
.Value = False then rng3 = "NA"
IF ws1.OleObjects("CheckBoxBedrockL4") _
.Value = False then rng4 = "NA"
IF ws1.OleObjects("CheckBoxBedrockL5") _
.Value = False then rng5 = "NA"
Next

--
Regards,
Tom Ogilvy




"Excel-erate2004 " wrote in
message ...
Niether of those options will work in my situation, I dont think I've
structured my code the correct way. What I want it to do is if these
two conditions are met:

If WS2.OLEObjects("CheckBoxSpecies" & i).Object.Value = True

AND

If WS1.OLEObjects("CheckBoxBedrockL" & j).Object.Value =False


Then if those 2 options are met for each then display an NA in the cell
range thats listed

OR alternatively:

Loop thru the 29 checkboxes on sheet2 and those that are selected
(i.e. true) then loop thru the 5 checkboxes on sheet1 and those that
are not selected i.e. false place a NA in the Cell ranges as listed.

It should work out like this, the combination would vary of course
dependant upon the 2 conditions listed above, but each defined range is
directly correlated with each checkbox, for example:

IF CheckBoxBedrockL1=true Then do nothing to these Cells("C11, J11,
C27, J27")
IF CheckBoxBedrockL2=false Then enter an NA in these Cells("D11, K11,
D27, K27")
IF CheckBoxBedrockL3=true Then do nothing to these Cells ("E11, L11,
E27, L27")
IF CheckBoxBedrockL4=false Then enter an NA in these Cells("F11, M11,
F27, M27")
IF CheckBoxBedrockL5=false Then enter an NA in these Cells("G11, N11,
G27, N27")

I'm not sure if that clarifies what I'm trying to do, I hope so because
I'm stuck.


---
Message posted from http://www.ExcelForum.com/