I am encountering a strange error when trying to use VBA to implement some formulas. Here is the formula I'm using to place "0.00%" instead of an error message in my cells:
ActiveWorkbook.Sheets("SM Summaries").Range("F6").FormulaR1C1 = "=IFERROR(RC[-2]/RC[-1], ""0.00%"")"
Now it places the 0.00% just fine, but even when its cell type is defined as percentage, if I sort largest to smallest by % it places the 0s at the top...
Here you can see where the 0s are placed on top even when doing largest to smallest. And the cell types are set properly to percentage as well:
Any idea what's going on here?
I have also tried just placed in 0.00 instead of 0.00% as well as 0% and "0", all of those options still showing 0 as being considered a "large number". The only reason that they're not green in the picture above is because I set a conditional formatting rule to stop turning 0s green (when the number is greater than 1).
The ""0.00%"" is putting the value in as text. And as such when Excel Sorts Descending it puts Text first.
You need to just put in 0 and format the cells as percent. So replace the ""0.00%"" with 0. No quotes. The quotes are forcing the number to text.
ActiveWorkbook.Sheets("SM Summaries").Range("F6").FormulaR1C1 = "=IFERROR(RC[-2]/RC[-1], 0)"
Related
I've created a Time Sheet for my dog walkers to fill in. They enter TIME STARTED and TIME ENDED for each of their dog walks and then a TOTAL TIME is generated using the =X-Y formula. This TOTAL TIME is formatted to be displayed in hh:mm but its true VALUE is a long integer.
Using the MATCH and INDEX functions, I've set up a formula to match the TOTAL TIME value generated to an index on the "Payment Schedule" sheet and locate the respective payment.
I keep getting errors that state the total time VALUES can't be matched but I know that formatting isn't the issue and the values are clearly on the "Payment Schedule" sheet. And when the MATCH function does return a row it returns the incorrect row, which locates the incorrect payment/rate.
Here is the Google Sheets I'm having trouble with.
Found the answer on another website:
it's floating point rounding error on the time values. I don't fully
understand what's happening, but I was able to reproduce it on my
system, and I found a work-around: Change your formula to
=INDEX(B:B, MATCH($I$4+TIME(0,0,1), A:A)) This adds one second (TIME(0,0,1); the arguments are TIME(hours,minutes,seconds)) to the I4
value; that seems to be enough to get it "over the hump", so that it
tests as being ≥ the value in A4 (or A7 or A10). BTW, I tried
TIME(0,0,0.9), but apparently TIME() won't honor fractional seconds,
and so it just treats that as TIME(0,0,0); i.e., just plain zero. If
you want to get a millisecond, you can use TIME(0,0,1)*0.001.
link
I have a cell in excel which contains a value, lets say 100000.
Now i want this value to have commas in between them to represent the thousands and millions i.e. 100,000. I can do this by changing the number format in the home menu.
Now i want this value to be copied from that cell and paste it as a label for a shape. When i am doing this the commas go away showing me just the numbers.
I want it to happen through VBA but this is not happening in excel itself.
Does anyone have a plausible solution for this?
In range object use Text property, like this:
Sheet1.Shapes(1).TextFrame.Characters.Text = Range("A1").Text
I have applied following format on excel cell. ##0\%;[Red]\(##0\%\)
This format is rounding off the value and showing negative number in red color within brackets.
issue: small values such as -0.03 is shown as (0%) instead of coming as 0%. showing 0 as negative does not make any sense.
What should i do to force -0 to be shown as 0 instead of (0).
Thank you
It will color and parenthesise your number based on its actual value, not how it displays.
Hence, it you don't want that showing up, you need to change the actual value, such as with:
=trunc(<current formula>,0)
or (most likely better):
=round(<current formula>,0)
Alternatively, you can apply conditional formatting to a cell so that the given formatting is only applied if, for example, round(<this cell>,0) = 0.
In that case, you could apply "##0\%" if the rounding results in 0 or your current format "##0\%;[Red]\(##0\%\)" otherwise.
I am trying to link cells in excel on two different work sheets.
I am using the formula eg: cell1 = cell2 + cell3. The numbers that I have in cell2 and cell3 are in format of 100% (1) and 50% (2). I just want to add numbers 1 and 2 so that my cell1 will have number 3.
Is it possible to do without changing the cell formats?
Thanks a lot.
If you don't care about the percentages, just copy your column with the percentages and change the format of that column to value and in sheet 2, do addition on that column instead.
Unfortunately when a cell has a format of percentage and a user enters a number, it is converted into what it means given the context of the format. It's not like what is being displayed is wildly different than what is 'hidden' inside the cell. When you reformat a cell, that data is reformatted as well, so 50% becomes .5 even if you had originally entered 50 in the cell before changing it's format. Format is more than just 'display format' so maybe that's where the confusion is.
If you want to add the cells in the percentage row and not bother with reformatting the formula cell you can cheat and treat it as a string to get rid of that %. You could do =Left(A2+A3, Len(A2+A3)) that will give you the 1.5 answer without having to format te cell.
Not sure i understood your question but i'll give some elements:
formula and formats are separated in Excel, thus, you can set a formula in A1, say =A2+A3 but displays the value the way you wish
for instance, if A2 contains 100% and A3 contains 50%, then the result in A1 is worth 1.5
you can set the format of A1 the way you wish (Right-clic > Format cells > Number tab), for instance, decimal, the cell will then display 1.5 but if you choose percentage, the cell will then display 150%
Please elaborate your question if needed.
[EDIT] New answer thanks to your comment:
If i understand well, you want to sum up the values between brackets in your cell (whatever is before, event percentages in your case).
Then, you can try this in cell A3:
=MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1 )+MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1 )
I am having problem with excel formula bar when formula exceeds 1024 characters.
It is not accepting formula and giving "out of memory" run time error when i am setting the formula from vb6 code.
Are there any settings in excel to increase the maximum length of a formula bar?
Thanks in advance.
In Excel 2003 the maximum number of characters in a cell is 32,767, all of
which will show up in the formula bar, but only 1024 will show up in the cell
itself.
And that 1024 "limit" can be broken by adding alt-enters every 80-100
characters, too.