Hi could someone explain to me exactly what the code below is doing especially the IF Statements
Thanks in advance
![]()
Please Login or Register to view this content.
Hi could someone explain to me exactly what the code below is doing especially the IF Statements
Thanks in advance
![]()
Please Login or Register to view this content.
the if statements are checking specific characters in B1. if the last char is '.' then the O1 is assigned a value of 1 (no clue why it uses a formula instead of a value) then the dec01 routine is run. if the second last char in B1 is a '.' then O1 equals 2 and dec02 is run and so on
the first If statement is duplicated for some reason and the whole thing looks inefficient to me ;-)
Josie
if at first you don't succeed try doing it the way your wife told you to
it checks if "." is within the first "x" characters of the right side of "B1". It's done in a queer way though. Then it proceeds to enter some values in "o1"
If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.
All those extra Ifs can be removed. Your code can be re-written as -
![]()
Please Login or Register to view this content.
Last edited by arlu1201; 10-15-2012 at 08:31 AM. Reason: Removed extra end if at the end.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Ok thanks for your comments
The code is suppose to check the number of decimal places of the value in "B1" then run a rountine to format other cells to that number of decimal places
It all seems to work well for example with the folling values
0.1, 0.01, 0.002
But if "B1" = 1 then it doesnt
any ideas please
I think you should use the function:
INSTR(1, Range("b1"), ".")
Last edited by Cutter; 10-15-2012 at 01:16 PM. Reason: Removed whole post quote
Don't forget to mark your thread as [SOLVED].
it works fine if i put in 1. instead of 1
ok what does that code do?
dont know the function INSTR
in your else part you assign 0 to o1 but then don't do anything else
it would be simpler to use
to put the number of decimal places in O1. I'm not sure why you need separate routines based on the different number of dp.![]()
Please Login or Register to view this content.
Thanks very much got it sorted now
How do i put this thread as solved?
May try to use the INSTR function if this will run better?
Thanks again everyone
how to mark your thread as Solved
New quick method:
Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.
Or you can use this way:
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks