Multiply each row with another all rows

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,</SPAN></SPAN>

I got some results in the columns C:E in this example there are 4 rows</SPAN></SPAN>
And some results in the columns G:I in this example there are 6 rows</SPAN></SPAN>
I need to multiply each row of Column C:E with all rows of column G:I so it will be 4*6=24 rows as shown the result into columns L:Q </SPAN></SPAN>
Note: if possible I want alternate font colours red and blue in the result area as per multiplied results. </SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQ
1
2
3
4
5n1n2n3n4n5n6n1n2n3n4n5n6
636106232523610623252
7353326319403610631940
821030438493610643849
943381991536106915
105436361065436
11243833610624383
1235332623252
1335332631940
1435332643849
15353326915
163533265436
1735332624383
182103023252
192103031940
202103043849
2121030915
22210305436
232103024383
2443381923252
2543381931940
2643381943849
27433819915
284338195436
2943381924383
30
31
32
33
Sheet4


Thank you all</SPAN></SPAN>

Excel 2000</SPAN></SPAN>
Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG26Jul32
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Rng1 [COLOR="Navy"]As[/COLOR] Range, Dn1 [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Col1 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Col2 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("C6", Range("C" & Rows.Count).End(xlUp))
[COLOR="Navy"]Set[/COLOR] Rng1 = Range("G6", Range("G" & Rows.Count).End(xlUp))
c = 5: Col1 = 5: Col2 = 3
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
   Col1 = IIf(Col1 = 3, 5, 3)
   Col2 = IIf(Col1 = 5, 3, 5)
   [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn1 [COLOR="Navy"]In[/COLOR] Rng1
     c = c + 1
     Cells(c, 12).Resize(, 3).Value = Dn.Resize(, 3).Value
     Cells(c, 12).Resize(, 3).Font.ColorIndex = Col1
     Cells(c, 15).Resize(, 3).Value = Dn1.Resize(, 3).Value
     Cells(c, 15).Resize(, 3).Font.ColorIndex = Col2

   [COLOR="Navy"]Next[/COLOR] Dn1
[COLOR="Navy"]Next[/COLOR] Dn
Range("L1").Resize(c, 6).Font.Bold = True
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Solution
Try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG26Jul32
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, Rng1 [COLOR=navy]As[/COLOR] Range, Dn1 [COLOR=navy]As[/COLOR] Range, c [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Col1 [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Col2 [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range("C6", Range("C" & Rows.Count).End(xlUp))
[COLOR=navy]Set[/COLOR] Rng1 = Range("G6", Range("G" & Rows.Count).End(xlUp))
c = 5: Col1 = 5: Col2 = 3
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
   Col1 = IIf(Col1 = 3, 5, 3)
   Col2 = IIf(Col1 = 5, 3, 5)
   [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn1 [COLOR=navy]In[/COLOR] Rng1
     c = c + 1
     Cells(c, 12).Resize(, 3).Value = Dn.Resize(, 3).Value
     Cells(c, 12).Resize(, 3).Font.ColorIndex = Col1
     Cells(c, 15).Resize(, 3).Value = Dn1.Resize(, 3).Value
     Cells(c, 15).Resize(, 3).Font.ColorIndex = Col2

   [COLOR=navy]Next[/COLOR] Dn1
[COLOR=navy]Next[/COLOR] Dn
Range("L1").Resize(c, 6).Font.Bold = True
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
MickG, I did check what I got max rows 280 one side and 224 other side 280*224= 62720 it worked really perfect and alternate font colouring is fine too.</SPAN></SPAN>

I appreciate your prompt replay. Have a good weekend
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti :-D
</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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