Formula Reference Error in new Worksheet

kimberly99

New Member
Joined
Apr 18, 2006
Messages
20
In Sheet1 cell A5 I entered the formula:

=COLUMNS($A1:C$1)

Cell A5 displays the number “3” as it should. I want to reference this formula in Sheet2 (you may ask why, the answer is I’ve simplified the actual task, so I only ask the root problem here). When I enter the formula:

=Sheet1!(COLUMNS($A1:C$1)) in any cell in Sheet2, instead of getting “3” I get error message “The formula you typed contains an error.”

What is my error?

Thanks,
Kim
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,389
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try:
Code:
=COLUMNS(Sheet1!A1:C1)
 

kimberly99

New Member
Joined
Apr 18, 2006
Messages
20
Thank you JoeMo, that worked (!).

However, to take it a step further, using the same logic on a longer formula, this did not work in Sheet2, and again I get error message:

=INDIRECT(Sheet1!"A"&COLUMNS(A1:C1))

Do you know what my error is here attempting to reference Sheet1?

Thanks,
kim
 

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623
In Sheet1 cell A5 I entered the formula:

=COLUMNS($A1:C$1)

Cell A5 displays the number “3” as it should. I want to reference this formula in Sheet2 (you may ask why, the answer is I’ve simplified the actual task, so I only ask the root problem here). When I enter the formula:

=Sheet1!(COLUMNS($A1:C$1)) in any cell in Sheet2, instead of getting “3” I get error message “The formula you typed contains an error.”

What is my error?

Thanks,
Kim
Put the sheet name in with the cell references...

=COLUMNS(Sheet1!$A1:C$1)

However, the sheet name is irrelavant to the result the function returns.

Even though the sheet name is included in the argument, the function does not reference back to Sheet1.

Both of these will return the exact same result:

=COLUMNS($A1:C$1)
=COLUMNS(Sheet1!$A1:C$1)

The only reson to include the sheet name is that when viewing the bigger formula that contains this expression, it may make it more intuitive.

Along those same lines, you really don't need to make the row reference absolute:

=COLUMNS($A1:C1)

The row number is also irrelavant to the result the function returns.
 

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623

ADVERTISEMENT

Thank you JoeMo, that worked (!).

However, to take it a step further, using the same logic on a longer formula, this did not work in Sheet2, and again I get error message:

=INDIRECT(Sheet1!"A"&COLUMNS(A1:C1))

Do you know what my error is here attempting to reference Sheet1?

Thanks,
kim
You have to quote the sheet name.

=INDIRECT("Sheet1!A"&COLUMNS(A1:C1))
 

kimberly99

New Member
Joined
Apr 18, 2006
Messages
20
Thanks Valco,
That worked. I would not have guessed "Sheet1!A" as the reference for "A" on Sheet1.

The reason I was using absolute cell references in the formula:

=INDIRECT("Sheet1!A"&COLUMNS($A1:B$1))

is so I can auto-fill horizontally on Sheet2 the above formula, so that it gives me the values in the "A" column of Sheet1. And it works! (I spent two hours last nite trying to figure that out, unsuccessfully).

Thanks!
Kim
 

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623
Thanks Valco,
That worked. I would not have guessed "Sheet1!A" as the reference for "A" on Sheet1.

The reason I was using absolute cell references in the formula:

=INDIRECT("Sheet1!A"&COLUMNS($A1:B$1))

is so I can auto-fill horizontally on Sheet2 the above formula, so that it gives me the values in the "A" column of Sheet1. And it works! (I spent two hours last nite trying to figure that out, unsuccessfully).

Thanks!
Kim
You're welcome. Thanks for the feedback! :cool:
 

Watch MrExcel Video

Forum statistics

Threads
1,123,318
Messages
5,600,921
Members
414,416
Latest member
Nobu

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