Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-2008, 12:36 PM
gimpemon@gmail.com
 
Posts: n/a
String as Formula without Macro / VBA

Hi,

I'm trying to create a formula dynamically by concatenating a number
of cells into a string which represents the my desired formula,
however, I can't get excel to accept the result as a formula. Instead
it displays it as a string.

The formula I'm trying to create is a sum across multiple sheets:

=SUM(SC1:OP1!K11) I.e. Sum K11 on all tabs from SC1 to OP1.

The problem is that SC1 and OP1 may change name and the number of
sheets between them / their order may also change. I've set up an
array of the sheet names such that the 1st value in the array is the
first sheet to sum from and the last position in the array is the last
sheet.

I'm then concatenating the results as follows:

="=SUM("&INDEX(Division_Names,
1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11)"

Which returns the desired =SUM(SC1:OP1!K11)

HOWEVER, excel reads this as a string, not a formula!!! It's driving
me mad!!

I know using VBA it's possible easily, something along the lines of:

Sub Formula()
First_Div = Range("G17").Text 'SC1
Last_Div = Range("G18").Text 'OP1
ActiveCell.Formula = "=SUM(" & First_Div & ":" & Last_Div & "!K11)"
End Sub

Unfortunately I'm not allowed macros (don't ask) so what I need is to
be able to tell Excel that the string is in fact a formula (i.e.
replicate the .Formula VBA instruction).

I've seen only a few posts on this, but nothing that seems to work. I
don't seem to be able to pass a multiple sheet range to the INDIRECT
function either.

=SUM(INDIRECT(INDEX(Division_Names,
1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11") )

Also doesn't seem to work??

Any help more than appreciated!
Reply With Quote
  #2 (permalink)  
Old 05-21-2008, 01:28 PM
Niek Otten
 
Posts: n/a
Re: String as Formula without Macro / VBA

Without VBA you can't enter a string as a formula AFAIK.
Do look at the INDIRECT() function in HELP, which may be all you need.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

<gimpemon@gmail.com> wrote in message news:ce7cf717-27eb-46f5-9bc0-c51a0b6018c8@26g2000hsk.googlegroups.com...
| Hi,
|
| I'm trying to create a formula dynamically by concatenating a number
| of cells into a string which represents the my desired formula,
| however, I can't get excel to accept the result as a formula. Instead
| it displays it as a string.
|
| The formula I'm trying to create is a sum across multiple sheets:
|
| =SUM(SC1:OP1!K11) I.e. Sum K11 on all tabs from SC1 to OP1.
|
| The problem is that SC1 and OP1 may change name and the number of
| sheets between them / their order may also change. I've set up an
| array of the sheet names such that the 1st value in the array is the
| first sheet to sum from and the last position in the array is the last
| sheet.
|
| I'm then concatenating the results as follows:
|
| ="=SUM("&INDEX(Division_Names,
| 1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11)"
|
| Which returns the desired =SUM(SC1:OP1!K11)
|
| HOWEVER, excel reads this as a string, not a formula!!! It's driving
| me mad!!
|
| I know using VBA it's possible easily, something along the lines of:
|
| Sub Formula()
| First_Div = Range("G17").Text 'SC1
| Last_Div = Range("G18").Text 'OP1
| ActiveCell.Formula = "=SUM(" & First_Div & ":" & Last_Div & "!K11)"
| End Sub
|
| Unfortunately I'm not allowed macros (don't ask) so what I need is to
| be able to tell Excel that the string is in fact a formula (i.e.
| replicate the .Formula VBA instruction).
|
| I've seen only a few posts on this, but nothing that seems to work. I
| don't seem to be able to pass a multiple sheet range to the INDIRECT
| function either.
|
| =SUM(INDIRECT(INDEX(Division_Names,
| 1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11") )
|
| Also doesn't seem to work??
|
| Any help more than appreciated!


Reply With Quote
  #3 (permalink)  
Old 05-21-2008, 01:56 PM
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
 
Posts: n/a
RE: String as Formula without Macro / VBA

Create two new tabs, alpha and omega; arrange that alpha is ALWAYS the first
sheet and omega is ALWAYS the last sheet. Both sheet will be empty. then:

=SUM(alpha:omega!K11)

will always encompass all the sheets
--
Gary''s Student - gsnu2007i


"gimpemon@gmail.com" wrote:

> Hi,
>
> I'm trying to create a formula dynamically by concatenating a number
> of cells into a string which represents the my desired formula,
> however, I can't get excel to accept the result as a formula. Instead
> it displays it as a string.
>
> The formula I'm trying to create is a sum across multiple sheets:
>
> =SUM(SC1:OP1!K11) I.e. Sum K11 on all tabs from SC1 to OP1.
>
> The problem is that SC1 and OP1 may change name and the number of
> sheets between them / their order may also change. I've set up an
> array of the sheet names such that the 1st value in the array is the
> first sheet to sum from and the last position in the array is the last
> sheet.
>
> I'm then concatenating the results as follows:
>
> ="=SUM("&INDEX(Division_Names,
> 1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11)"
>
> Which returns the desired =SUM(SC1:OP1!K11)
>
> HOWEVER, excel reads this as a string, not a formula!!! It's driving
> me mad!!
>
> I know using VBA it's possible easily, something along the lines of:
>
> Sub Formula()
> First_Div = Range("G17").Text 'SC1
> Last_Div = Range("G18").Text 'OP1
> ActiveCell.Formula = "=SUM(" & First_Div & ":" & Last_Div & "!K11)"
> End Sub
>
> Unfortunately I'm not allowed macros (don't ask) so what I need is to
> be able to tell Excel that the string is in fact a formula (i.e.
> replicate the .Formula VBA instruction).
>
> I've seen only a few posts on this, but nothing that seems to work. I
> don't seem to be able to pass a multiple sheet range to the INDIRECT
> function either.
>
> =SUM(INDIRECT(INDEX(Division_Names,
> 1)&":"&INDEX(Division_Names,Num_Divisions)&"!K11") )
>
> Also doesn't seem to work??
>
> Any help more than appreciated!
>

Reply With Quote
  #4 (permalink)  
Old 05-21-2008, 06:09 PM
gimpemon@gmail.com
 
Posts: n/a
Re: String as Formula without Macro / VBA

Thanks to both you for your swift replies. I've opted for Gary's
soln, which was the temporary fix I was already using.

Shame the VBA action isn't possible....

Best,
Greg
Reply With Quote
  #5 (permalink)  
Old 05-21-2008, 06:20 PM
Excel@shoenfeltconsulting.com
 
Posts: n/a
Re: String as Formula without Macro / VBA

I don't understand how you're defining the range names Division_Names
& Num_Divisions. But I suspect that you may be able to do what you're
trying to do with "Dynamic Range names". Are you familiar with this?
Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:53 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Mortgage | TurboTax Software | MPAA | Loans | Free Advertising



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114