• 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.

VBA Code to Multiply 2 Cells

New VBA User

New Member
Hello All,

I have an excel sheet where the user will input values in 2 columns. I am looking for VBA code that will show the multiplied result in 3rd column

Col A ColB ColC
3 7 21
6 6 36
 
Private Sub CommandButton1_Click()

Dim i As Integer

For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Cells(i, 3).Value = Cells(i, 1).Value * Cells(i, 2).Value


Next i

End Sub
 
Hi !

Less efficient is a loop - like ForNext - when an Excel feature
already exists like here an easy formula :​
Code:
Sub Demo()
    With [A1].CurrentRegion.Resize(, 3).Columns
        .Item(3).Value = Evaluate(.Item(1).Address & "*" & .Item(2).Address)
    End With
End Sub
Same as Belleke post #3 but via a direct evaluation …

Think Excel Before VBA !

Do you like it ? So thanks to click on bottom right Like !
 
Back
Top