1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. 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...

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

Discussion in 'VBA Macros' started by New VBA User, Nov 10, 2017.

  1. New VBA User

    New VBA User New Member

    Messages:
    8
    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
  2. Derek McGill

    Derek McGill Active Member

    Messages:
    135
    Why vba and not a formula ?
  3. Belleke

    Belleke Active Member

    Messages:
    151
    Try:
    Code (vb):
    Sub Belleke()
    With Range("C1:C" & Range("A" & Rows.Count).End(xlUp).Row)
            .Formula = "=PRODUCT($A1, $B1)"
            .Value = .Value
          End With
    End Sub
    Thomas Kuriakose and Hui like this.
  4. Akash Goswami

    Akash Goswami New Member

    Messages:
    3
    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
  5. Marc L

    Marc L Excel Ninja

    Messages:
    3,225
    Hi !

    Less efficient is a loop - like ForNext - when an Excel feature
    already exists like here an easy formula :​
    Code (vb):
    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 !

Share This Page