conditionally change the value after decimal

If column J is BUY Then add the number after decimal  so that the second value after decimal comes to 5 or 0  and after it comes to 0 then remove all the value after decimal second value
If column J is SELL then  subtract the number  after decimal so that the second  value after decimal comes to 5 or 0  and after it comes to 0 then remove all the value after decimal  second value

plz see the sample file
Sachin SinghAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
What result do you want if the the number is 1615.0114?
What result do you want if the the number is 1615.6114?
Sachin SinghAuthor Commented:
If column J  is BUY  then 1615.05
If column J is SELL then  1615.60
Martin LissOlder than dirtCommented:
Does this work for you? It assumes that the number to be changed is in column 'Z'. You'll need to format the output column to be a number with 2 decimals.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Sachin SinghAuthor Commented:
Yes Martin Sir
But i want the vba code to do this  and change the data to column G and column L see the sample file
so plz look into it
Gustav BrockCIOCommented:
Define your source range and your target range.
Then loop these while copying/setting the values using this function:

Public Function RoundBuySell( _
    ByVal InputValue As Double, _
    ByVal BuySell As String) _
    As Double

    Dim OutputValue As Double
    Select Case BuySell
        Case "BUY"
            OutputValue = -Int(-InputValue * 20) / 20
        Case "SELL"
            OutputValue = Int(InputValue  * 20) / 20
    End Select
    RoundBuySell = OutputValue
End Function

Open in new window

It either rounds up or down as you have requested.
Sachin SinghAuthor Commented:
Thnx Martin Liss  Sir and Gustav Brock  Sir for ur  Great Support
Gustav BrockCIOCommented:
Hmm, no points for an excellent function ...
Sachin SinghAuthor Commented:
i have given both half half Sir
Gustav BrockCIOCommented:
Great! Have a nice day.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.