• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how can i work on percentage's in VBA

ananthram

New Member
Hi All,


i have 2 columns with values and i need it to calculate as percentages. like, if A and B Column has 100 and 50 then i need it to calculate as 100% and 50%. Please help.
 
Hi Ananth Ram ,


Your problem description is not sufficiently clear ; please take an example or two , and explain what you mean by the phrase :


if A and B Column has 100 and 50 then i need it to calculate as 100% and 50%


100% is actually 1 , and 50% is actually 0.5 ; do you mean that if A2 has a value such as 50 , any formula using it should use 0.5 ?


If this is so , then just add the %sign to the cell address ; for example , if A1 has the value 100 , and B1 has the value 50 , then , if in C1 , you put in the formula :


=A1%+B1%


then C1 will display 1.5


Narayan
 
Hi Ananth Ram ,


I am not sure I have understood your requirement , but try this :

[pre]
Code:
Public Sub Calculate_As_Percentages()
Dim input_data As Range
Set input_data = ActiveSheet.Range("A1:B7")      '  Change as required

For Each cell In input_data.Resize(, 1)
cell.Offset(, 2).Value = cell * cell.Offset(, 1).Value * 0.0001
Next
End Sub
[/pre]
Narayan
 
Back
Top