0
Thanks

A few words of thanks would be greatly appreciated.

Excel - Sorting numbers from 1 to 100 in rows of 10

Microsoft Excel is the tool of choice for many when it comes to creating, storing or handling data for day to day use. Excel can be used for arranging data in various ways like outputting numbers from 1 to 100 in rows of 10. To do this, one can write a custom code in VBA which uses nested loops for outputting numbers from 1 to 100 in rows of 10. One important thing to note here is that the actual value of the cell is populated based on the index of the loops in play.


Issue


Could someone help me with Excel? How to output the numbers 1 to 100 (10 rows with 10 columns) using a For loop? So far I have the following:

For x = 1 To 10        
Cells(1, x) = x        
Next x        

For x = 1 To 10        
Cells(2, x) = x + 10        
Next x 


etc...

This works but I would like to make the code as short as possible. As you can guess I'm new at using Excel so any help would be much appreciated.

Solution


Hello try this:

for i=1 to 100        
for j=1 to 100        
cells(i,j)=i*j        
next j        
next i 

Note that


Thanks to Excelguru for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Related

This document, titled « Excel - Sorting numbers from 1 to 100 in rows of 10 », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments