View Single Post
  #19   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

if you have excel, you have an immediate window

in the view menu in the VBE, select immediate window

for other types, you loop 1 to 5, so for the given row, you walk across the
row

c d e f g j k l m n

and the same for 26 rows down - but you have now merged all those cells, so
not sure what the code is supposed to do. Should it not loop 1 to 5 if the
type is PelagicL?

It looks like you have it set up correctly - so with that change, looping 1
to 5, if any evaluate to false it should put NA in C20, J20, C36, J36



--
Regards,
Tom Ogilvy


"Excel-erate2004 " wrote in
message ...
Back again,

Hopefully I can get this solved so I can leave you alone lol,

I'm not sure where in fact the problem is coming from in regards to the
Merged cells at the bottom of my tables, if it is in fact that.

I dont have VS2000 so the Immediate Window is not an option for me to
look at.

The problem again is that in 2 of 4 merged cell areas the "NA" tag is
applied when the checkbox is set to false, as it should be.

However, in the other 2 merged areas the tag is not applied at all
when the checkbox is set to false.


I'm not sure if this makes any sense at all, but diagramtically I have
a large Table with 4 mini tables within it [See attached image]

Table1 Table2
Merged area 1 Merged area 2
Works fine NA applied Does not work NA not applied
(C20:G20) (J20:N20)


Table3 Table4
Merged area 3 Merged area 4
Works fine NA applied Does not work NA not applied
(C36:G36) (J36:N36)



I also tried your suggestion but on clicking it didnt do anything.

Do I have it set up properly?




Code:
--------------------

Dim WS1 As Worksheet, WS2 As Worksheet
Dim Rng As Range
Dim varr As Variant
Dim i As Long, j As Long, k As Long
Dim jj As Long, baserow As Long, baserow1 As Long

Dim rngArr(1 To 4) As Range 'newly added to test
Dim LL As Long ' newly added to test


Set WS1 = Sheets("Step 1")
Set WS2 = Sheets("Step 2")

varr = Array("BedrockL", "BoulderL", "RubbleL", "CobbleL", _
"GravelL", "SandL", "SiltL", "ClayL", "MuckL", "PelagicL")

For i = 1 To 29
If WS2.OLEObjects("CheckBoxSpecies" & i) _
.Object.Value = True Then
baserow = (i - 1) * 38 + 11
jj = -1
For j = LBound(varr) To UBound(varr)
jj = jj + 1
baserow1 = baserow + jj
For k = 1 To 5
If WS1.OLEObjects("CheckBox" & _
varr(j) & k).Object.Value = False Then

Set Rng = WS2.Cells(baserow1, 2 + k)
Set rngArr(1) = Rng
Set rngArr(2) = Rng.Offset(16, 0)
Set rngArr(3) = Rng.Offset(0, 7)
Set rngArr(4) = Rng.Offset(16, 7)

For LL = 1 To 4
Set Rng = rngArr(LL).MergeArea(1)
Rng.Value = "NA"

End If

Next
Next
End If
Next


--------------------



I'm so close thanks to all your help but its just this last little snag
that I hope I can get thru.

Thanks

Attachment filename: tables.gif
Download attachment:

http://www.excelforum.com/attachment.php?postid=664161
---
Message posted from http://www.ExcelForum.com/