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

October 2017

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.

## Related

Published by aakai1056. Latest update on May 21, 2012 at 09:02 AM by aakai1056.