Multiplication by percent

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I have values:

Values (col a)Percent (col b)Result (col c)
20220.4
30531.5
104010.4

<tbody>
</tbody>

equation should looks:
result = 20 * 1.02 = 20.4
result = 30 * 1.05 = 31,5
result = 10 * 1.4 = 14

How can I do it into Vba? Because I doing now as below: (result is the same)

Code:
ws.Range("C2").Value = (ws.Range("A2").Value * ws.Range("B2").Value / 100 ) + ws.Range("A2").Value
ws.Range("C3").Value = (ws.Range("A3").Value * ws.Range("B3").Value / 100 ) + ws.Range("A3").Value
ws.Range("C4").Value = (ws.Range("A4").Value * ws.Range("B4").Value / 100 ) + ws.Range("A4").Value
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Code:
Sub Percent()

Dim ws As Worksheet
Dim LastRow As Long
Dim rng1 As Range


Application.ScreenUpdating = False


Set ws = Sheets("Sheet1")
With ws
    LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
    
    Set rng1 = Range(.Cells(2, 2), .Cells(LastRow, 2)).Offset(, 1)
    With rng1
        .Formula = "=A2 * (1+(B2/100))"
        .Copy
        .PasteSpecial xlValues
    End With
End With


Application.ScreenUpdating = True


End Sub
 
Upvote 0
I don't want to use Formula. Calculation should be done into VBa and then display just result.
 
Upvote 0
Code:
Sub Percent()


Dim ws As Worksheet
Dim LastRow As Long
Dim rng1 As Range
Dim cell As Range


Application.ScreenUpdating = False


Set ws = Sheets("Sheet1")
With ws
    LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
    
    Set rng1 = Range(.Cells(2, 2), .Cells(LastRow, 2)).Offset(, 1)
    For Each cell In rng1
        cell.Value = cell.Offset(, -2) * (1 + (cell.Offset(, -1) / 100))
    Next
End With


Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,932
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top