There are a lot of ways of accomplishing this task. There needs to be more specific instructions on what you really want to accomplish to let programmers responding to you know what you are doing and how you hope to accomplish it so we can work within your framework. I'll list 2 ways you can do this.
This one uses a formula to calculate the value for each cell:
Code:
Public Sub PlaceNumbersUsingRowCol()
'Places numbers using formula with row and column numbring from 1 to 100 left to right
' and top to bottom in cells A2 through E21 and changes background color for all cells
'Declaring variables correctly makes coding easier & enables office's built in auto complete
Dim wsTarget As Worksheet, rCellOn As Range
Set wsTarget = Me
With wsTarget
.Range("A2:E21").Interior.Color = RGB(0, 150, 0)
For Each rCellOn In .Range("A2:E21") 'For each itterates through a set of objects sequentially
rCellOn.Value = (rCellOn.Row - 2) * 5 + (rCellOn.Column) 'used formula to calculate #'s
Next
End With
Set wsTarget = Nothing
End Sub
Another way to do this is to track the number yourself. This is a little less elegant but may help clarify how for/each loops (left to right, top to bottom):
Code:
Public Sub PlaceNumbersUsingOwnVariable()
'Declaring variables correctly makes coding easier & enables office's built in auto complete
Dim wsTarget As Worksheet, rCellOn As Range, iCounter As Long
Set wsTarget = Me
With wsTarget
.Range("A2:E21").Interior.Color = RGB(0, 150, 0)
For Each rCellOn In .Range("A2:E21") 'For each itterates through a set of objects sequentially
iCounter = iCounter + 1 'Calculate my own number
rCellOn.Value = iCounter 'Place my own value in the current cell from For/Each loop
Next
End With
Set wsTarget = Nothing
End Sub
I very rarely use offset, preferring to be specific and track cell positions myself. However if you wish to use your method, you can just add a line to place the number. I'd still put the color in the entire range first to reduce number of actions to desired goal:
Code:
Public Sub Make_Table()
'/===================================================================
'/
'/===================================================================
Dim nRowCounter As Integer
Dim nColCounter As Integer
For nRowCounter = 1 To 20
For nColCounter = 0 To 4
With ThisWorkbook.Worksheets(1).Range("A1").Offset(nRowCounter, nColCounter)
.Interior.Color = RGB(0, 150, 0)
.Value = (nRowCounter - 1) * 5 + nColCounter + 1
End With
Next
Next
End Sub
Notice I use with so I don't have to type the entire line referring to the same cell over & over again.
Still not sure what your actual question/need is but I hoped this helped point you in the right direction.