VBA - Smallest number in range (greater than -1)

Beachson

Active Member
Joined
Oct 28, 2009
Messages
468
How would I state the following in VBA? ...

Code:
If ActiveCell.Offset(0, 1) > -1 AND _
   ActiveCell.Offset(0, 2) > -1 Then

   ActiveCell.Offset(1, 0)

Else

Below is my question on how to state in VBA. Would go right after "Else" in the above code" ...

Smallest number (must be greater than -1) in the range of ActiveCell.Offset(0, 2):ActiveCell.Offset(0, 5)

Thanks for any help everyone
 
I was not very clear on this question and obviously asked it incorrectly. Sorry everyone ...

My desired result was achieved by the following (the question I had is in red) ...

Code:
If ActiveCell.Offset(0, 1) > -1 AND _
   ActiveCell.Offset(0, 2) > -1 Then

   ActiveCell.Offset(1, 0)

Else

[COLOR=#ff0000]Selection.FormulaArray = "=MIN(IF(RC[1]:RC[4]>-1,RC[1]:RC[4]))"

[/COLOR]End If

I'm confused :confused:
RC[1]:RC[4] corresponds to Offset(0,1):Offset(0,4) not Offset(0,2):Offset(0,5) as you stated in post 1
What do you really want?

M.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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