#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default BEDMAS

Hi All,

I'm trying to create a spreadsheet that will generate an assignment
for my students on the use of "BEDMAS" - order of operations. I plan
to print it out and give it to them, and that part is working fine. I
am having trouble getting Excel to take the data and calculate it. I
know it's possible, but I just can't get it to work. :-)

Here's what I've got in cells (for example):

A B C D E F G H I J K L M N

a) ( 4 "" * "" 2 ) - "" 7 "" = ______
b) "" 3 "" + ( 4 "" * "" 8 ) = ______

I've managed to concatenate b through L so that it reads (4*2)-7, but
I can't find a way to get Excel to actually compute that answer. Is
there anyone out there that has any ideas?

Thanks in advance for your help!

Dave

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default BEDMAS

You're going to need some VBA. Is that ok?

If it is, you could use a UDF like:

Option Explicit
Function Eval(rng As Range) As Variant

Dim myCell As Range
Dim myStr As String
Dim Res As Variant

myStr = ""
For Each myCell In rng.Cells
myStr = myStr & myCell.Value & " "
Next myCell

Res = Application.Evaluate(myStr)

If IsError(Res) Then
Eval = "Error!"
Else
Eval = Res
End If

End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=eval(a1:N1)




wrote:

Hi All,

I'm trying to create a spreadsheet that will generate an assignment
for my students on the use of "BEDMAS" - order of operations. I plan
to print it out and give it to them, and that part is working fine. I
am having trouble getting Excel to take the data and calculate it. I
know it's possible, but I just can't get it to work. :-)

Here's what I've got in cells (for example):

A B C D E F G H I J K L M N

a) ( 4 "" * "" 2 ) - "" 7 "" = ______
b) "" 3 "" + ( 4 "" * "" 8 ) = ______

I've managed to concatenate b through L so that it reads (4*2)-7, but
I can't find a way to get Excel to actually compute that answer. Is
there anyone out there that has any ideas?

Thanks in advance for your help!

Dave


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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



All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"