Searching a range of cells for a cell with a value greater than 0 then placing the adjacent cell to another cell

woodsm

New Member
Joined
Apr 14, 2016
Messages
3
Sorry for the long title.

I have two columns, the first column is of numbers, the second column is text. I want to search the first column for a cell with a value that is greater than 0. Then place the adjacent cell on a separate sheet, which is the an invoice.

I know how to search the first column for a specific number value. I do not know how to search the first column for a single cell that has a value "greater than 0".

The first column has 10 cells, only one of them will have a value, but the value could be "1", "2", "3" etc. All the other cells will have an "0" in them.

The second row will have a name that needs to be placed into a different sheet. The name will be adjacent to the cell with a value greater than "0".

Any help will be appreciated. Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Change Sheet and Cell references as required
Code:
Sub Maybe()
    Dim MaxVal As Long
    MaxVal = Application.WorksheetFunction.Max(Sheets("Sheet1").Range("A1:A10"))
    Sheets("Sheet2").Range("B3").Value = Range("A1:A10").Find(MaxVal).Offset(, 1).Value
End Sub
 
Upvote 0
Try

=LOOKUP(2,1/(A1:A100>0),B1:B100)

Assuming the number in Column A, and the text to return in column B
 
Last edited:
Upvote 0
Upvote 0
Thanks Jonmo1,

I am looking to take the answer from column b and place it in a different column. I am getting a #DIV/0! error also.

A B

0 Sally
0 Mike
0 Tom
2 Fred
0 Steve

I want to retrieve Fred's name and place it in column "f" or on a different page by searching the first column. The number "2" may be a "1", "3", "4" etc.
 
Upvote 0
Thanks Jolivanes,

I am a newbie and do not understand anything you typed. The formula I used was =vlookup(1,A2:A10,2,0). But this would only return values of 1, again the lookup value of "1" can be anything greater than 0. I was trying to put ">0" where the 1 is in the formula. I do not know if this is even possible.
 
Upvote 0
Please read Post #4 and provide the links as requested on both sites.
After that, google on how to insert code into excel and how to use a macro in Excel.
I am sure that you'll get a site that is way better at explaining this then I can.
The code I gave you does what you want but if you want/need a formula, you'll have to get it from someone else.

BTW, If you change jonmo's formula to "=LOOKUP(2,1/(Sheet1!A1:A10>0),Sheet1!B1:B10)" and put it anywhere in another sheet, also in Column F, it'll give you the desired result.
Of course, the ranges A1:A10 and B!:B10 need to be just that and that data has to be in Sheet1. If not, change accordingly.
 
Last edited:
Upvote 0
I am looking to take the answer from column b and place it in a different column.
That's what the formula I posted does


Excel 2013
ABCD
10SallyFred
20Mike
30Tom
42Fred
50Steve
Sheet1
Cell Formulas
RangeFormula
D1=LOOKUP(2,1/(A1:A100>0),B1:B100)
 
Upvote 0
@Jonmo1
Good evening.
I think he/she wants it in another sheet according to his/her first post.
No biggie.
Have a good remainder of your evening.
John
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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