I am trying to set up Excel for my D&D Fantasy Currency.
I want to use Excel to convert integers and decimals to gold (gp), silver (sp), and copper (cp) pieces; e.g. 25.47 = 25gp 4sp 7cp.
The conversion is fairly simple, as seen on this conversion table or below.
1sp = 10cp
1gp = 10sp = 100cp
I got this code from an answer that user4039065 posted on as similar question asked by Juddson Ivines - How to format fantasy currency in Microsoft Excel?:
=TRIM(TEXT(INT(J6),"0 \g\p ;;;")&TEXT(--RIGHT(TEXT(J6,"0.0")),"0 \s\p ;;;")&TEXT(--RIGHT(TEXT(J6,"0.00")),"0 \c\p ;;;"))
This code at first glance worked amazingly.
However when it came to converting 0.6 to 6cp, the code messes up and answers as 1cp 6sp. For some reason the code is adding 1sp.
A further error occurs at 0.95-0.99, where it drops the 9sp entirely.
I even gridded out from 1cp to over 2gp to check for errors, which you can see here, which is how I caught the 0.95 error.
Thanks to user4039065 for their answer and starting code, as well as Juddson Ivines for asking the original question.
Apologies for being new here and my lack of being able to embed my images.
I would really appreciate some help with correcting the format of this code.
Formula in column C is:
=TRIM(IF(B5>=1;INT(B5)&"gp ";"")&IF(B5-INT(B5)>=0,1;MID(B5-INT(B5);3;1)&"sp ";"")&IF(LEN(B5-INT(B5))>3;VALUE(MID(B5-INT(B5);4;2))&"cp";""))
You may benefit from several functions to achieve this. The tricky part is to get an IF for each type of coin and also avoid left zeros in the copper coins (that's the VALUE duty)
Probably sometimes you may get weird output due to decimals. You just need to Round the values.
I'm comparing values of numbers from 2 data sheets, and I've dropped the relevant data from both into their own arrays. I need to find matching values to run other steps of analysis.
For i = Lbound(Array1) to UBound(Array1)
For j = LBound(Array2) to UBound(Array2)
If (criteria for Array2) then
variable = 11111
Else
variable = 22222
End if
If variable = Array1(i,1) Or variable = Array1(i,2) or variable = Array1(i,3) then
more steps
Else
more steps
End if
next j
next i
The first if statement sets the variable correctly, but the variable doesn't match any of the criteria. It doesn't go to the else like it should. Now I only know this because I walked through the code step by step. If I just F5 and run the thing, "Excel is not responding". I don't know what the hang up it. All of my variables are declared and assigned a type, I'm not missing any closing statements. And I have no idea what I'm doing wrong.
What do I need to check for in my code?
EDIT
Sorry, but in this instance I'm not allowed to upload any code here. It's work related, NDA kind of stuff. Hence the pseudo code. What I need to show wouldn't be a big deal(at least I don't think it would), but I'm not risking it.
My apologies.
The solution, as it turns out, has to do with a poorly named array(not me) and a simple typo(definitely me). I'm certain that would have been an easy solve for the good citizens of Stack Overflow if I would have been allowed to post actual code.
For what's it worth, I think it's dumb that I couldn't in this case. Thanks #ScottCraner and #SuperSymmertry for trying to be helpful even without much to go on.
Super, I'm still curious about Val. If you've got a minute, I would appreciate more knowledge on that. Anything from an actual person is better than Microsoft documentation.
=O27&" "&IF(D27<>"",VLOOKUP(D27,성취기준1반!$B$4:$C$19,2)&" ","")&IF(E27<>"",VLOOKUP(E27,성취기준1반!$E$4:$F$19,2)&" ","")&IF(F27<>"",VLOOKUP(F27,성취기준1반!$H$4:$I$19,2)&" ","")&IF(G27<>"",VLOOKUP(G27,성취기준1반!$K$4:$L$19,2)&" ","")&IF(H27<>"",VLOOKUP(H27,성취기준1반!$N$4:$O$33,2)&" ","")&IF(I27<>"",VLOOKUP(I27,성취기준1반!$Q$4:$R$33,2)&" ","")&IF(J27<>"",VLOOKUP(J27,성취기준1반!$T$4:$U$33,2)&" ","")&IF(K27<>"",VLOOKUP(K27,성취기준1반!$W$4:$X$33,2)&" ","")&IF(L27<>"",VLOOKUP(L27,성취기준1반!$Z$4:$AA$33,2)&" ","")&IF(M27<>"",VLOOKUP(M27,성취기준1반!$AC$4:$AD$19,2)&" ","")&P27
this is working code
=O28&" "&IF(D28<>"",VLOOKUP(D28,성취기준1반!$B$4:$C$19,2)&" ","")&IF(E28<>"",VLOOKUP(E28,성취기준1반!$E$4:$F$19,2)&" ","")&IF(F28<>"",VLOOKUP(F28,성취기준1반!$H$4:$I$19,2)&" ","")&IF(G28<>"",VLOOKUP(G28,성취기준1반!$K$4:$L$19,2)&" ","")&IF(H28<>"",VLOOKUP(H28,성취기준1반!$N$4:$O$33,2)&" ","")&IF(I28<>"",VLOOKUP(I28,성취기준1반!$Q$4:$R$33,2)&" ","")&IF(J28<>"",VLOOKUP(J28,성취기준1반!$T$4:$U$33,2)&" ","")&IF(K28<>"",VLOOKUP(K28,성취기준1반!$W$4:$X$33,2)&" ","")&IF(L28<>"",VLOOKUP(L28,성취기준1반!$Z$4:$AA$33,2)&" ","")&IF(M28<>"",VLOOKUP(M28,성취기준1반!$AC$4:$AD$19,2)&" ","")&P28
this is doesn't workin code.
Why doesn't it work?
This is not an answer in terms of a solution, but an answer in terms of the method you could employ to find and solve the issue. Mainly because you have not provided a working verifiable example, data or detail of the actual error.
First I would remove the vlookups and replace them with the expected results - if that then functions as it should then each of the vlookups needs to be tested, if not then check the detail of the function.
Appreciate if you can assist by explaining.. "why this doesn't work?" part. It is an error message or the the expected value is _ but I got _ instead.. (:
One thing I noticed is that you don't define what will be the outcome if D28 is "". If you don't define it, it'll return 'FALSE' value instead of a String/text.
In your IF() function, you only say IF(d28<>"",<DisplayValueFrom성취기준1반>) it should be IF(d28<>"",<DisplayValueFrom성취기준1반>,<DisplaySomeThingElse>)
I just made an awful formula in excel, which is:
=SUM(A1*C1, A2*C2, A3*C3 ... ... A21*C21)
I was forced to type the 21 elements one by one manually and still have no idea on how to solve the problem despite of long time Google searching...
Is there any elegant way that can solve such situation in more smart manner? ( maybe something like: =SMART_SUM(A1*C1 : A21*C21) )
thanks for your attention!
This is a typical use case for SUMPRODUCT
=SUMPRODUCT(A1:A21,C1:C21)
Reading the documentation, I'm led to believe Google Docs should be able to handle if-statements in the following format (straight from the documentation):
IF(test, then_value, otherwise_value)
So, as a test, I try the following:
=IF(2>1, 2, 1)
This should obviously print 2 since two will always be greater than one. However, this throws me an error. So, I try the following instead:
=IF(1=1, 1, 1)
This also gives me an error.
Obviously I'm doing something wrong here, unless Google stopped supporting if-statements in their docs. Can anyone help?
Google has obviously changed this without changing the proper documentation. According to the documentation, as of writing this, the correct way to do this is as in my question:
=IF(2>1, 2, 1)
However, if you start writing "=IF" in Google Drive, a popup guides you in the correct direction, and it seems they have changed the syntax to:
=IF(2>1; 2; 1)
Note the use of semicolons instead of commas. That's it.