how do I find next value?

DannyDoobster

New Member
Joined
Mar 6, 2009
Messages
8
I have a table like the sample below. If a or b or c is 1, I want to find the first instance of a 1 in d or e or f. By using Match function I get the row in which the first instance occur, but what I want is in which column(s) (d or/and e or/and f) the first instance of 1 occur.

For example, 1 is recorded in a1, then offset in d4. Next, 1 is recorded in b6 then offset in d8 AND f8.



. A B C D E F
1 0 0 0 0 0 0

2 1 0 0 0 0 0

3 0 0 0 0 0 0

4 0 0 0 1 0 0

5 0 0 0 0 0 0

6 0 1 0 0 0 0

7 0 0 0 0 0 0

8 0 0 0 1 1 0



any help would be much appreciated!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, Try:-
Code:
Sub One()
Dim cl As Range, Num As String
For Each cl In UsedRange
    If cl = 1 Then
        Num = Num & cl.Address & Chr(10)
    End If
Next cl
MsgBox "The Following Cells have a ""1"" in them " & Chr(10) & Num
End sub
 
Upvote 0

DannyDoobster

New Member
Joined
Mar 6, 2009
Messages
8
Thanks for your reply MickG

I'm not overly comfortable using coding. is there away of doing it using Excel functions?

cheers
Danny
 
Upvote 0

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, This UDF is the best I can do !!
Open your sheet, Click "Alt+F11" , Vb window appears.
On VB Toolbar Select "Insert", "Module".
Paste the entire code into the New window.
Close VB Window.
To Run the function, enter, =One( Select your range here !!!)
The function will return the addresses of the cells in Range with a "1".
Code:
Function One(Rng As Range) As String
Dim cl As Range, Num As String
For Each cl In Rng
    If cl = 1 Then
        Num = Num & cl.Address & ","
    End If
Next cl
One = Num
End Function
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,190,959
Messages
5,983,863
Members
439,867
Latest member
Shadrack

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
Top