Previous in Forum: Php Programming   Next in Forum: Installation of Microsoft Visual Studio 2008
Close
Close
Close
20 comments
Rate Comments: Nested
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1

Excel Question

05/10/2012 10:18 PM

Ok.. I have tried to solve this problem all day and now I am asking for help

What I Have: I have a cell in excel where I input a value (A1). Lets say I put a value of 101. Next to it in cell B1, I have a drop down list that shows the units of A1. Now it is Pa.

What I want: After I put in 101 | Pa, I change B1 drop down list to atm, and I want it to automatically update the value in cell A1 to 1 | atm.

I hope you can understand my question.

You input is appreciated.

Thanks

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru

Join Date: Jun 2010
Posts: 1296
Good Answers: 104
#1

Re: Excel Question

05/10/2012 11:49 PM

I can't help with your exact question, but how about if you put the 'convert from' in A1 and B1 like you said, but put the 'convert to' in other cells, say C1 and D1?

This is probably not the most elegant way, but it should work. I only have Excel 2000, so newer versions may have better tools available. I'll assume you intend to extend this concept to many units conversions.

You are using data validation to get the values for the units in B1 and D1, so you must have tables with these values somewhere else in you spreadsheet. Do the conversion in 2 steps. Use one cell, say Z1, as a temporary holding spot. Put a formula in Z1 to convert the input to some consistent unit of pressure, say psi, by multiplying A1 by a value from a lookup table on B1. Then, in C1, put a formula to convert from psi in Z1 to whatever units are selected in D1 by multiplying Z1 by a value in a lookup table on D1. (I'm thinking 2 lookup tables, each with one column of units (text) and the other with conversion factors (numbers).

Register to Reply
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#8
In reply to #1

Re: Excel Question

05/12/2012 2:10 AM

Why do you still have excel 2000... Excel 2010 has a lot of new features that would make excel 2000 look like the apple II to the mac book air..

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply
Guru

Join Date: Jun 2010
Posts: 1296
Good Answers: 104
#17
In reply to #8

Re: Excel Question

05/13/2012 10:04 PM

Would you like to contribute to the 'bigg software acquisition fund'? I've used newer versions, but when it comes to forking out the $, 2000 does everything I need at home.

Register to Reply
Guru
United Kingdom - Member - Indeterminate Engineering Fields - Control Engineering - New Member

Join Date: Jan 2007
Location: In the bothy, 7 chains down the line from Dodman's Lane level crossing, in the nation formerly known as Great Britain. Kettle's on.
Posts: 32175
Good Answers: 839
#2

Re: Excel Question

05/11/2012 6:50 AM

There isn't sufficient intelligence in Excel to do this. It needs to know that Pa ia a unit of pressure, and atm also, and how to inter-relate them. Further, by updating A1, it would disappear up its own exhaust pipe: how many iterations would it need to carry out (rhetorical question)? The intention is just one, though Excel would need to know this.

It can't do it in the way described, though there are innumerable other ways of doing it, as suggested in #1↑.

__________________
"Did you get my e-mail?" - "The biggest problem in communication is the illusion that it has taken place" - George Bernard Shaw, 1856
Register to Reply Score 1 for Off Topic
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#9
In reply to #2

Re: Excel Question

05/12/2012 2:11 AM

There is no intelligence in software, its the intelligence of the programmer, and sadly, my intelligence is not up to this specific task..

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply Score 1 for Good Answer
Guru

Join Date: Aug 2009
Location: Glen Mills, PA.
Posts: 2385
Good Answers: 114
#3

Re: Excel Question

05/11/2012 11:27 AM

You could use nested If/then/else tests.

__________________
In a time of universal deceit, telling the truth is a revolutionary act. George Orwell
Register to Reply
Guru
Popular Science - Cosmology - New Member Engineering Fields - Civil Engineering - New Member Engineering Fields - Nuclear Engineering - New Member United States - Member - New Member

Join Date: Aug 2010
Posts: 714
Good Answers: 38
#4

Re: Excel Question

05/11/2012 12:33 PM

The only way I can see to do it is to do some programming in VBA. I think PW is right in that using just the built-in functions for the cells, excel won't do it.

__________________
Sometimes my thoughts are in a degree of order so high even I don't get it...
Register to Reply
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#10
In reply to #4

Re: Excel Question

05/12/2012 2:13 AM

You are correct.. I used

Private Sub Worksheet_Change(ByVal Target As Range)

and it works beautifully!

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply
2
Power-User

Join Date: Mar 2012
Location: Hot Humid Houston
Posts: 229
Good Answers: 29
#5

Re: Excel Question

05/11/2012 10:57 PM

You can write a macro that executes when you click on B1.

In english - if B1 is Pa do macro Pa to atm. If B1 is atm do macro atm to Pa.

Macro will copy A1 value to a second or hidden sheet or cell then delete A1 value.

You can't reference the A1 value in the other table for the reasons others have stated, you would have recursion and Excel can't stop that madness.

Paste A1 value to conversion table on sheet 2

Perform calculation.

Copy new resultant value.

Paste to sheet one A1.

Change value of B1 to other unit designator.

Stop macro.

Next click on B1 will execute the opposite conversion and change B1 back to the other units.

__________________
txmedic3338
Register to Reply Good Answer (Score 2)
2
Guru
Engineering Fields - Nuclear Engineering - New Member

Join Date: Sep 2009
Location: Louisville, OH
Posts: 1925
Good Answers: 36
#6

Re: Excel Question

05/11/2012 11:13 PM

I'm not an Excel expert, so this is a WAG. (For expert opinion, there is a computer supporter's group conference in North Canton, OH, in the middle of July. One of the presenters wrote a book on Excel.)

On to my WAG: I suspect you need a third cell to put the 101 in (which would always be Pa or some convenient unit), and a formula in A1 to multiply this cell by a conversion factor. What I am not sure about is: can a Lookup table look at cell B1 and determine the conversion factor from the B1 contents--that is Pa, atm, or whatever. If you want to include units other than pressure, the Lookup would be horrendously long!

__________________
Lehman57
Register to Reply Good Answer (Score 2)
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#7
In reply to #6

Re: Excel Question

05/12/2012 2:07 AM

It is possible, and I did it.. the secret is a routine by the nameof Worksheet_change..

Here is a very generic version for you to use.

Thanks for the input..

Private Sub Worksheet_Change(ByVal Target As Range) Dim OldUnit As Variant Dim NewUnit As Variant Dim ConversionFactor As Double If Target.Cells.Count = 1 And Target.Column = 2 Then ' Save new units NewUnit = Target ' prevent recalling this code when we update cells Application.EnableEvents = False ' Get old units Application.Undo OldUnit = Target ' put new units back on sheet Target = NewUnit ' work out your conversion factor based on old and new units ConversionFactor = 0.5 ' for testing ' update value Target.Offset(0, -1) = Target.Offset(0, -1) * ConversionFactor Application.EnableEvents = True End If End Sub

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply Score 1 for Good Answer
Guru
Technical Fields - Project Managers & Project Engineers - New Member

Join Date: Aug 2006
Location: Midwestern United States
Posts: 843
Good Answers: 76
#11
In reply to #7

Re: Excel Question

05/12/2012 7:28 AM

One question though:

If this overwrites the original value with the converted value, how do you check your work?

Part of doing calculations/conversions is having enough documented information to check your end result. Or else THIS might happen.

__________________
Reuters - Investigators found that the recent thread derailment in CR4 was caused by over-weight creatures of lore and request that membership DON'T FEED THE TROLLS.
Register to Reply
Commentator

Join Date: Nov 2010
Posts: 88
Good Answers: 4
#12
In reply to #11

Re: Excel Question

05/12/2012 7:41 AM

All any computer program can ever do is execute the logic imposed by the user/programer. Internal logic checks, and spell check can only go so far. When I want to check out a new routine, I input either 1 or zero for each of the input data. That way the converted number shows up as the conversion factor and is easily recognizable. Likewise when zero is input it will show or confirm the logic.

Register to Reply
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#15
In reply to #11

Re: Excel Question

05/12/2012 3:51 PM

This is correct. I am doing this calculation for another company and I have to make sure that I can catch all the possible user errors. I am thinking of scrapping this idea all together and going with what Stewart has suggested and using a table to covert all inputs into standard working units used througout..

By the way, it is an interesting article you have linked to.. Bjarne Stroustrup recently gave a talk about the new C++ standard and good coding practice, and he mentioned this as well...

He suggested that all numeric values used in programming be assigned a unit and he showed a routine that basically checks for correct units all the time.. I would like to find something similar in excel

As engineers, we are always wary of keeping the right units when doing a calculation, but when making a calculation worksheet for other engineers/nonengineers to use, the issue becomes extremely important.

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply
Guru
Engineering Fields - Nuclear Engineering - New Member

Join Date: Sep 2009
Location: Louisville, OH
Posts: 1925
Good Answers: 36
#13

Re: Excel Question

05/12/2012 9:37 AM

For this and other Excel questions, try:

Google "MrExcel." Or go to MrExcel.com. You should find that Bill Jelen is Mr. Excel; he has a book about Excel. He is the one who will be a presenter at out NE Ohio Computer User's Conference.

Another is one that I often get ads from. ExcelTips by Allen Wyatt. Book name is ExcelTips: Times and Dates. Check store.tips.net/T010154 and T010155.

__________________
Lehman57
Register to Reply
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
Good Answers: 162
#14

Re: Excel Question

05/12/2012 3:37 PM

I got a working conversion by: (1) providing input fields in Excel in one worksheet for the value , starting units, units sought, and results fields for the conversion factor in the units sought, and the final result in the units sought. (2) in a separate worksheet, I prepared a table with the input unit as row label, and output unit as column header of known conversion factors for 10 different units of pressure (listed in alphabetical order for no apparent reason), (3)used the "match" and "address" functions in Excel to find the cell reference to the necessary constant, and (4) used the "indirect" function to get the value from the table. From this point it was a simple calculation in Excel to arrive at the final answer. Works every time, as long as you type in the unit correctly.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply Score 1 for Good Answer
Power-User
Hobbies - Automotive Performance - New Member Hobbies - CNC - New Member

Join Date: Jun 2008
Location: Long Island, NY
Posts: 326
Good Answers: 1
#16
In reply to #14

Re: Excel Question

05/12/2012 3:54 PM

May I have a look at what you have done? I can send you my email..

__________________
It is better to fail in originality than to succeed in imitation.
Register to Reply
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
Good Answers: 162
#18
In reply to #16

Re: Excel Question

05/14/2012 1:59 PM

I would simply attach the file, but I have not figured out a way to do that on this blog.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply
Guru

Join Date: Jun 2007
Posts: 1035
Good Answers: 40
#19
In reply to #18

Re: Excel Question

05/15/2012 12:44 PM

Re: "...have not figured out a way to do that on this blog"

You could upload the file to your personal webspace/file-area (provided by your ISP), and then send a LINK to it via "Personal Message" to any individual, or place the link in a msg here, if you wanted *anyone* to be able to look at it.

((Or, there are many 'File-Sharing' sites available, if you do not have your OWN space available...then, likewise, provide a LINK to it))

Register to Reply
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
Good Answers: 162
#20
In reply to #19

Re: Excel Question

05/17/2012 3:41 PM

Thanks, I sent the file to the interested party. If he wants to share it, it's up to him.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply
Register to Reply 20 comments

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

bigg (2); ChaoticIntellect (1); Davesets (1); Economist (6); James Stewart (3); JavaHead (1); Lehman57 (2); ndt-tom (1); passingtongreen (1); PWSlack (1); txmedic3338 (1)

Previous in Forum: Php Programming   Next in Forum: Installation of Microsoft Visual Studio 2008

Advertisement