convert string to mathematical expression

Hello,

what's wrong with below code ?
I want to get result of equation.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


firstnumber = InputBox("Please, give me first number")

secondnumber = InputBox("Please, give me second number")
Myoperator = InputBox("Please give me an operator, for example + or - ")
Myresult = Val(firstnumber) & Myoperator & Val(secondnumber)

wiersz = Range("A1").Row



Myresult = Val(Myresult)
Cells(wiersz, 1).Value = firstnumber
Cells(wiersz, 2).Value = Myoperator
Cells(wiersz, 3).Value = secondnumber
Cells(wiersz, 4).Value = "="
Cells(wiersz, 5).Value = Myresult


0
43t4 (5)
9/3/2010 4:27:42 PM
excel 39879 articles. 2 followers. Follow

4 Replies
357 Views

Similar Articles

[PageSpeed] 23

I'm not sure why your code doesn't work (perhaps someone else could explain 
it), but either of the following lines will put a formula into Cells(wiersz, 
5) instead of a value, giving you the displayed result you need.

Cells(wiersz, 5).Formula = "=" & Cells(wiersz, 1).Value & Myoperator & 
Cells(wiersz, 3).Value
Cells(wiersz, 5).Formula = "=" & firstnumber & Myoperator & secondnumber

You don't need the 3 lines referring to Myresult.

--
Ian
--

"Nateysz" <43t4@vbr.pl> wrote in message 
news:4c812279$0$20989$65785112@news.neostrada.pl...
> Hello,
>
> what's wrong with below code ?
> I want to get result of equation.
>
> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>
>
> firstnumber = InputBox("Please, give me first number")
>
> secondnumber = InputBox("Please, give me second number")
> Myoperator = InputBox("Please give me an operator, for example + or - ")
> Myresult = Val(firstnumber) & Myoperator & Val(secondnumber)
>
> wiersz = Range("A1").Row
>
>
>
> Myresult = Val(Myresult)
> Cells(wiersz, 1).Value = firstnumber
> Cells(wiersz, 2).Value = Myoperator
> Cells(wiersz, 3).Value = secondnumber
> Cells(wiersz, 4).Value = "="
> Cells(wiersz, 5).Value = Myresult
>
>
> 


0
me1 (409)
9/3/2010 5:57:52 PM
Can you tell us what problem(s) you are experiencing?

Do you want to put a formula in a cell or actually evaluate that
formula in the code?

0
9/4/2010 2:28:44 PM
W dniu 04.09.2010 16:28, norie pisze:
> Can you tell us what problem(s) you are experiencing?
>
> Do you want to put a formula in a cell or actually evaluate that
> formula in the code?
>

I want to evaluate that formula, but as I tell, it's always only string 
not equation which Excel should proceed
0
43t4 (5)
9/11/2010 12:01:51 AM
On Fri, 3 Sep 2010 18:27:42 +0200, "Nateysz" <43t4@vbr.pl> wrote:

>Hello,
>
>what's wrong with below code ?
>I want to get result of equation.
>
>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>
>
>firstnumber = InputBox("Please, give me first number")
>
>secondnumber = InputBox("Please, give me second number")
>Myoperator = InputBox("Please give me an operator, for example + or - ")
>Myresult = Val(firstnumber) & Myoperator & Val(secondnumber)
>
>wiersz = Range("A1").Row
>
>
>
>Myresult = Val(Myresult)
>Cells(wiersz, 1).Value = firstnumber
>Cells(wiersz, 2).Value = Myoperator
>Cells(wiersz, 3).Value = secondnumber
>Cells(wiersz, 4).Value = "="
>Cells(wiersz, 5).Value = Myresult
>

Try:


=====================
Myresult = Evaluate(firstnumber & Myoperator & secondnumber)

wiersz = Range("A1").Row

Cells(wiersz, 1).Value = firstnumber
Cells(wiersz, 2).Value = Myoperator
Cells(wiersz, 3).Value = secondnumber
Cells(wiersz, 4).Value = "="
Cells(wiersz, 5).Value = Myresult
=============================
0
ron6368 (329)
9/11/2010 1:29:12 AM
Reply:

Similar Artilces:

Converting Leads 01-04-06
When converting multiple Leads associated with the same Account - shouldn't CRM 3.0 recognize that association and put them under one Account? I am seeing our CRM create duplicate Accounts (and contacts for that matter but I know it does not do dup-detection) I convert 5 ABC company Leads to Contacts and Accounts I should end up with ONE Account and 5 contacts associated with that Account. Is that right? Any advice? No, it is doing what you are telling it to do. You are telling it to create a new Account, so it is creating a new Account. Unfortuanately, there is no provided way ...

Convert expression to code
Hi All, I have a conditional formatting expression i would like to convert to code, and need some help! I want the code to be in the OnOpen event of a report (called rptAllInformation). If the value of [DIA FORM ISSUED] is more than 6 weeks ago, and [DIA RESPONSE RECEIVED] is null, then label (lblOverdueWarning) becomes visible At the moment the expresson is: [DIA RESPONSE RECEIVED] Is Null And [DIA FORM ISSUED]<DateAdd("w",-6,Date()) Can anyone help? Kirstie "Kirstie Adam" <kirstiea@ecosse.net(nospam)> wrote: >Hi All, > >I have a conditiona...

Has anyone converted an MS Access VBA project to .Net?
I am looking for any information regarding the conversion of an MS Access VBA project with backend of Oracle to either Visual Basic or VB.Net. Has anyone done any conversion like this and if so, do they have any recommendations, issues to share? Thanks! ...

Converting to Money 2004 from Quicken2002
I am trying to decide whether to stick with Quicken or move to Money. TaxCut and MS are offering a good rebate but I cannot convert my data with the trial edition of Money. It provides the very useful message,"Your Quicken file could not be converted." I sometimes wonder if they pay people to think these up. Checking this group suggests that this is not an isolated incident. If I cannot convert, I cannot switch. There is too much to enter. Is there a log file somewhere that might tell me more? Thanks In microsoft.public.money, Otis Bricker wrote: >I am trying to decide whe...

Outlook Express will not send receipt
I have Windows Me, Outlook Express 5.0. I receive emails that request a receipt; I checked send receipt always and tried checking ask me first. It tries to send a receipt but then says something like "outlook was unable to send the receipt" It doesn't tell me why or how to fix it. Can anyone help? Thanks. ...

Expression Web
Hi Clive: Here you go. https://msdn.microsoft.com/en-us/subscriptions/securedownloads/details/defau lt.aspx?pm=pid%3a65%7CLk:t Go to his place and log him on from there, so he burns his bandwidth instead of yours :-) Take a re-writeable CD with you if he hasn't got one. The download arrives as an .iso file. The simplest thing to do is to simply burn the damn thing onto a CD and install from there. Otherwise, there's an application named ISOBuster you can download that enables you to mount an ISO as if it "were" a CD. The free version enables installation from within ...

Converting mails to tasks
Hi All, Is there a way where we can convert the incoming mails to tasks using some task template? If so, please let me know how. Thanks, Vinay. Check this page for some possibilities: http://www.slipstick.com/addins/tasks.htm -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:0b0301c3a9af$814353b0$a101280a@phx.gbl, Vinay Urs wrote: > Hi All, > > Is there a way where we can convert the incoming mails to > tasks using some task template? > > ...

Converting Money 2006 Business to Money Plus Premium
Last year I installed the Home & Business version of Money, but have found I do not really use the business features. I may begin to use the Accounting software. Will my present money file convert ok if I go back to using the Premium version for my personal finances? Thank you in advance. In microsoft.public.money, NaStein wrote: >Last year I installed the Home & Business version of Money, but have found I >do not really use the business features. I may begin to use the Accounting >software. Will my present money file convert ok if I go back to using the >Prem...

Excel, Percentof row D6:d13 with "Y" expressed in E5
How do I get a percent of D6:D13 with the letter "Y" in E5? hi try this.... =COUNTIF(D6:D13,"y")/COUNTA(D6:D13) this formula assumes that D6:D13 is all text. Regards FSt1 "Magic1" wrote: > How do I get a percent of D6:D13 with the letter "Y" in E5? oops you said "y" was in E5....so..... =COUNTIF(D6:D13,E5)/COUNTA(D6:D13) regards FSt1 "FSt1" wrote: > hi > try this.... > =COUNTIF(D6:D13,"y")/COUNTA(D6:D13) > > this formula assumes that D6:D13 is all text. > Regards > FSt1 > > "Magic...

outlook express #73
I have an identity on OE that requires a password and yet when i start up OE it does not promt for a pw. Anyone who uses my computer has access to all my accounts. I have had the same problem with win xp and 2000, both pro. I have checked all settings 5 times and downloaded all updates. The "require password" box is checked for the identity and there is only one identity on the machine. However I can start the computer and go right into OE without a pw. Any help would be appreciated <fake_em@hotmail.com> wrote in message news:010f01c3ac7b$b1a6cf40$a401280a@phx.gbl... &...

converting a number to a Julian Date
I am trying to take part of a claim number that is a Julian Date and translate it into a calendar date. Any suggestions on what to use in my query. Here are some examples of the 4 digit numbers: 9248 9230 9342 9345 Thank you - Lisa There are actually several different definitions of Julian Date. Which one are you trying to use? (In other words, to what should those four sample values equate?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "LisaK" <LisaK@discussions.microsoft.com> wrote in message news:...

Converter
I can not open Publisher documents created in another version of Publisher. I have office publisher 2000. Is there a converter file or something I need to download? thank you, Which version are you trying to open your P2000 files in? -- JoAnn Paules MVP Microsoft [Publisher] "Susan" <anonymous@discussions.microsoft.com> wrote in message news:2ad4201c46794$2d844380$a401280a@phx.gbl... >I can not open Publisher documents created in another > version of Publisher. I have office publisher 2000. > > Is there a converter file or something I need to download?...

Count partial matched text string
I have 3 spreadsheets. The first, “Supplies Requests Received” where Column B contains the (duplicated) names of internal offices placing supply requests (e.g., SNF, DGEN, CANM, etc.) and Column G contains each date a request for supplies was received from that office. Column B Column B SNF 1//29/2009 DGEN 4/19/2008 CNMN 2/4/2009 ASEV 12/11/2008 SNF 2/3/2009 ASEV 9/16/2008 DGEN 5/1/2008 The second spreadsheet “Supplies Delivered” where Column A is a link of Column B from the above “Supplies Requests Received spreadsheet and Column G (of Supplies Delivered”) contains the names of ALL ...

Converting Comments to Footnote Type References #2
I understand that Excel is not a word processor. What I wanted to kno is if there was a better way to anotate a spreadsheet. This i important for providing spreadsheet data (budgets in this case) i printed form to others. Referencing cell notes for these hardcop users would be much better if there were a supersrcipt reference numbe in a cell which then would match to comments at the bottom of the page. I'll try some of those macro suggestions you provided though. Thanks, Scot -- Planne ----------------------------------------------------------------------- Planner's Profile: ht...

American Express now on Yoddle ??
Hello All, I have been using Money to directly download all my transactions in to Money for a long time. It worked even in 2005 until a week ago. And then suddenly it started to error out. My accounts with other institutions still get updated. I then tried to cancel the Amex online service and re-enroll. I now see a new account being created in Money. When I tried to merge this with my actual account, it shows up duplicate entries, and cannot merge transactions. Wonder if anyone knows why this is happening Thanks SPC ...

Export/import Groups from Outlook Express
I am transfering files etc. to a new computer and need assistance exporting/importing Groups from Outlook Express. ... I have successfully exported / imported the Contact information, by Groups were not included. ... Thanks. RossD wrote: > I am transfering files etc. to a new computer and need assistance > exporting/importing Groups from Outlook Express. > .. > I have successfully exported / imported the Contact information, by Groups > were not included. > .. > Thanks. Backup and Restore OE http://insideoe.tomsterdam.com/backup/index.htm This newsgroup is for suppo...

Table name in Expression builder not allowed?
I tried to do a simple calculation (on a form) but fail to understand this: =[UnitPrice]*[Quantity] works, however if I use the Tables list from (below) and construct the formula it shows as: [OrderDetails].UnitPrice * [OrderDetails].Quantity and it does not work. I get #Name error When field names are written as [UnitPrice] is it not a standard practice to name them as such? Somewhere I also see [OrderDetails]![UnitPrice] notation. Why? Thanks "dindigul" <padhye.m@gmail.com> wrote in news:O9MdHWQEIHA.5752@TK2MSFTNGP02.phx.gbl: > I tried to do a simple calculation ...

I need to convert name 3 part name into Last, First MiddleNameorMI
I have a column of names, most of which are FirstName LastName in format. Some, however are First MiddleName (or MI) Last. I need to convert these values into LastName Firstname MI. I have a formula that gets close, but doesn't account for the possible presence of a Middle Name or initial. For ex, data could be Jill Smith, or Jo Ann Smith. I need to make Smith, Jill and Smith, Jo Ann. Seems like I need to go backwards thru the string with a Search function to find the 2nd space for this to work, but can't. Or should I try it by parsing consecutive columns with incremental chan...

Error on TransferText when converting Access 97 to Access Xp
The instruction TransferText is use to create a file from a table. This program works very well (many years) on access 97. Afer the convertion to access xp I have the error : "Cannot update .." I went to Newsgroups and see that for security reason MS oblige me to change my file extension .doc to a file extension .txt. So now, I use a text file and I have always on the TransferText instruction the error : "The insert into statement contains ...unknow field name" What can I do to resolve this convertion problem ? Thank you for advance for your answers. ...

Convert Paradox to Access
Hi I need some information on converting an existing Paradox database/app (version ??) into Access 2000/XP. I know nothing about Paradox, but do about Access. From what I have found, migrating the data into Access seems like it should be easy enough. My question relates to other aspects of Paradox, such as queries, and macros or code or triggers. Does Paradox contain all these items? Can these be migrated into Access easily, or are there programs out there which help? Are there any aspects to watch out for? Is there an 'easy' migration tool or something which basically co...

Converting Dates between Gregorian to Afghani Calendar
Hello, I need your help in creating a calendar that converts the dates fro Gregorian Calendar to Afghani Calendar. Afghani Calendar is sola calendar which mean it has 365 days. It is not Lunar Calendar. So yea 2006 = 1385 afghani calendar. So this mean that G= A + 621 and A= G 621. The problem I have is converting the months and days. The new year fo Afghani Calendar is march 20 or 21 (depends on which day is the firs day of spring). So the new year 1/1/2006 is 3/20/1385. I would like to create a excel file that does this conversion and a well show the month and days graphically. :rol...

How to convert attributes to element
Hello all, Can't figure it out. :( Assume that we have 2 XML document: Document1 (source): <elements> <elementA attribute1="value1" attribute2="value2" ... /> <elementA attribute1="value1" attribute2="value2" ... /> ... </elements> Document2 (element description): <elements> <element name="elementA"> <attributes> <attribute name="attribute1" description="Attribute1 desc" /> <attribute name="attribute2" description="Attribute2 desc...

Expression 09-10-07
I really don't know how to pose this question so I will give an example in Excel: Cell 2B is eaqual to Cell 2A - Cell1A I would like use a similar calculation in Access for all records in a field or calulate the different between the record in the same line and the previous record. I hope I gave edquate information. Charles -- Charles Message posted via http://www.accessmonster.com These example appear to use 2 diiferent control field, in my case I need to use the same field but find the difference between the raw. Excel Fromula CellA1 = 2 CellA2 = 1 Cell B2 = 3 CellA3 = 5 Cell B3 ...

convert equation to formula
Is there anyway to take an equation written in Equation editor and convert it to an Excel formula? You'll have to do that manually. And it is very interesting work. :) "DW in SF" <DW in SF@discussions.microsoft.com> wrote in message news:2FC66A71-338C-40CC-9B9C-32176388F3AF@microsoft.com... > Is there anyway to take an equation written in Equation editor and convert > it > to an Excel formula? I just Used the Equation Editor to record a Chemical Equation so I doubt that the editor can do this. However there is a "MATHFORMAT" that might do some ...

Outlook express doesnt work after installing critical updates
Today I installed microsofts critical updates for outlook express. I went to check my email and I keep getting the message: Outlook Express could not be started because MSOE.DLL could not be found. Outlook Express may not be installed properly. I have windows 2000, and this is really annoying, at least I know that I will never do any more critical updates for OE. Can anybody out there please please please help me. Thanks Lavinia ...