View Single Post
  #18   Report Post  
Posted to microsoft.public.excel.programming
Excel-erate2004[_30_] Excel-erate2004[_30_] is offline
external usenet poster
 
Posts: 1
Default Method 'Range' of Object_Worksheet Failed

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 th
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 t
look at.

The problem again is that in 2 of 4 merged cell areas the "NA" tag i
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 al
when the checkbox is set to false.


I'm not sure if this makes any sense at all, but diagramtically I hav
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 sna
that I hope I can get thru.

Thank

Attachment filename: tables.gif
Download attachment: http://www.excelforum.com/attachment.php?postid=66416
--
Message posted from http://www.ExcelForum.com