By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

Looping in Excel

P: 1
Hi there,i'm new to VB and need some help to write a looping script .
I need to write a macro in excel to multiply two column of data.The way I would like to multiply them are as below. Assume A and B are the two columns and 1,2,3,4..represent the data in each rows.
A1,A2,A3,A4.....B100
B1,B2,B3,B4.....B100
I would like to multiply them: A1*B1, A1*B2, A1*B3, A1*B4...A1*B100. After I finish with A1, I will continue with A2 ; A2*B1,A2*B3,A2*B4...A2*B100. This process will keep going with A3,A4...until A100...
Can someone please show me a simple script to perform this? many thanks in advance
Apr 28 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Hi there,i'm new to VB and need some help to write a looping script .
I need to write a macro in excel to multiply two column of data.The way I would like to multiply them are as below. Assume A and B are the two columns and 1,2,3,4..represent the data in each rows.
A1,A2,A3,A4.....B100
B1,B2,B3,B4.....B100
I would like to multiply them: A1*B1, A1*B2, A1*B3, A1*B4...A1*B100. After I finish with A1, I will continue with A2 ; A2*B1,A2*B3,A2*B4...A2*B100. This process will keep going with A3,A4...until A100...
Can someone please show me a simple script to perform this? many thanks in advance
Phew! Sounds as though you could end up with a might big number! :)

If you know the size of the selection, you could just use a couple of nested FOR loops. Something along the lines of...
Expand|Select|Wrap|Line Numbers
  1. For Col1 = 1 To N
  2.   For Col2 = 1 To N
  3.     Multiply ActiveSheet.Cells(1,Col1).Value by Multiply ActiveSheet.Cells(2,Col2).Value
  4.   Next
  5. Next
Note that this is not the exact syntax, just the overall idea.
May 1 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.