Need help with If Function between sheets

pearl11

New Member
Joined
Dec 16, 2010
Messages
30
I am trying to simplify having to input fixed information.

I have information on two excel sheets/tabs

One sheet is where i want to input data

the other sheet is where i want it to grab the info.

So if I put in 3 in A1, it will look on the second sheet and grab a number from B3 and place this number in A2 (on the first sheet).

If I put in 2 in A1, it will look on the second sheet and grab a number from B2 and place this number in A2 (on the first sheet).

I was able to figure out how to it for one number, but if you ask other numbers it doesn't work.

=IF(A1=3,Sheet2!B3)

so that formula works for the number 3. what if I put in the number 2 or 9 or 211?

Any suggestions?
 
sorry texanann, using the word counts is confusing

does what i just said before this help explain?
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What is your overall goal with this formula?
to save time and cut down on human error from getting data from different sheets

Here is what Sheet 2 looks like:

A B
Town
Weight Cost
1 7.89
2 8.15
3 8.97
 
Upvote 0
I think I see what you're needing now...

=VLOOKUP(A1,Sheet2!A:B,2,0)
 
Upvote 0
try it like this

Code:
=IF(A4=3,Sheet2!B3,IF(A4=2,INDIRECT("Sheet2!B" & (A1)+1),IF(A1=9,Sheet2!B9)))
 
Upvote 0
thanks tex

I like it when there is more than one way to solve an issue

i don't know if you'd want the additional challenge but what if instead of the same scenario i asked about between two sheets, it is between two excel files like excel1.xlsx and excel2.xlsx

you two really know your stuff.
 
Upvote 0
When referring between workbooks, you have to refer the workbook AND the worksheet. You have to encase the workbook reference in [square brackets] and encase the workbook AND worksheet reference in 'single quotes'

=VLOOKUP(A1,'[excel2.xlsx]Sheet2'!A:B,2,0)
 
Upvote 0
=VLOOKUP(A1,Sheet2!A:B,2,0)

this formula works incredibly well

It is late afternoon and I haven't had a coffee today so what usually comes easy isn't today.

I am trying to figure out what the A:B, 2,0 part of the above formula means.

any quick explanation?
 
Upvote 0
A:B refers to columns A through B.

2 refers to the column in the array to return (A is the first column, B is the second column)

0 refers to a TRUE/FALSE boolean, where TRUE will return the closest match (data must be sorted), and FALSE will return only an exact match.
 
Upvote 0

Forum statistics

Threads
1,215,949
Messages
6,127,892
Members
449,411
Latest member
AppellatePerson

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