Muliiplication of columns of two worksheets

NewToVBA1

New Member
Joined
May 22, 2011
Messages
20
Hi I am searching for a VBA code to multiply cells of one column from one worksheet to multiply with another column with another worksheet and paste the resulting column in a third worksheet. The wroksheets are not identical,ie., the columns are located in different in bot the worksheets. The rows with available data will change with time, so I need the code to search the available data only and do the multiplication.
Help will be very much appreciated.
Regards
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
There's not enough information to answer the question. How do you locate the data on each sheet?
 
Upvote 0
Thanks for the reply.
I will locate the column in each sheet by it column no. for example, I want to multiply Column D of Sheet1 to Column G od sheet2 and output the results in column I in Sheet3. Also, the number of row of the columns should be the last available data at the bottom.
 
Upvote 0
There's a number of different types of "multiplication" of columns you could do. Which do you want?

Maybe Cayley multiplication (the usual matrix MMult stuff that Excel does), Shur/Hadamard multiplication (where each individual cell iin one column is multiplied by each corresponding individual cell in other column), Kronecker multiplication (where each individual cell in one column is multiplied by all cells in other column), etc.

Outputs of whichever is used need to be arranged suitably (they'll look very different), and in some cases the numbers of relevant cells in each column need to be equal.
 
Upvote 0
Thanks.
I think I am looking for the second type that multiplies one cell of column A to another cell of Column B, for example:
Cell(1,5) of column A* Cell(1,8) of columnB , where the row number will be the same until the available data at the bottom of the columns. I will apprecaite if such a code is made available
Regards
 
Upvote 0
You might have a look at this code and see if it's on the lines of what you want.

You might have to change some addresses etc to suit your case.

Also, there's not much in the way of error trapping etc, but you're so imprecise about locations etc it's a bit hard to know how to allow for everything at this stage.

But post back if any problems.
Code:
Sub multiplycols()
Dim a As Range, b As Range
With Sheets("sheet1") 'or wherever one column is located
    Set a = .Range("C1")    'if colC specified
    If a = "" Then Set a = a.End(4)
    .Range(a, a(Rows.Count - a.Row).End(3)).Name = "aa"
End With
With Sheets("sheet2") 'or wherever other column is located
    Set b = .Range("D1")    'if colG specified
    If b = "" Then Set b = b.End(4)
    .Range(b, b(Rows.Count - b.Row).End(3)).Name = "bb"
End With
If Range("aa").Rows.Count <> Range("bb").Rows.Count Then
    MsgBox "Unequal row numbers in the ranges" & Chr(10) & _
        "What do you want to do about this?"
    Exit Sub
End If
cmult = Evaluate("=aa*bb")
Sheets("sheet3").Range("G4").Resize(UBound(cmult, 1)) = cmult
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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