Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / May 2008

Tip: Looking for answers? Try searching our database.

String as Formula without Macro / VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gimpemon@gmail.com - 21 May 2008 12:36 GMT
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!
Niek Otten - 21 May 2008 13:28 GMT
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.

Signature

Kind regards,

Niek Otten
Microsoft MVP - Excel

| Hi,
|
[quoted text clipped - 45 lines]
|
| Any help more than appreciated!
Gary''s Student - 21 May 2008 13:56 GMT
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
Signature

Gary''s Student - gsnu2007i

> Hi,
>
[quoted text clipped - 45 lines]
>
> Any help more than appreciated!
gimpemon@gmail.com - 21 May 2008 18:09 GMT
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
Excel@shoenfeltconsulting.com - 21 May 2008 18:20 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.