Error "object variable or with block variable not set" when comparing values in multiD array to single value

jadeliew

New Member
Joined
Sep 29, 2016
Messages
3
Hi guys.. i know this error has been posted several times but i can't seem to find the solution.

Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim buysignal As Range
Dim OHLC As Range
Dim ffdhigh As Range
Dim sellsignal As Range
Dim ffdlow As Range
Dim cll As Range
Dim i As Long
i = 1
Sheets("sheet2").Activate
Set OHLC = Range("B" & i & ":" & "E" & i)
Set ffdhigh = Range("I" & i)
Set buysignal = Range("M" & i)
Set cll = Range("B63")
For i = 63 To 150
    For Each cll In OHLC
    
        If cll.Value > ffdhigh.Value Then
        buysignal.Value = "buy"
        Else: buysignal.Value = ""
        End If
    Exit For
    Next
Next i

End Sub

The part highlighted is always the "If cll.Value > ffdhigh.Value Then" part.
As stated in my title what i want is to find the first value in the multidimensional array that is more than a single value.
any input will be very much appreciated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the forum.

As it stands your code makes no sense to me. You have a loop in which nothing changes and another which you always exit after the first pass. Could you explain what you are actually trying to do?
 
Upvote 0

Forum statistics

Threads
1,216,094
Messages
6,128,785
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top