I have a 3 column by 5 row grid and I am using the code below to put numbers in it, is there any way I can check and make sure the numbers in the first column, column C, are between 1-20 the second column between 21-40 and the third between 41-60, what I was thinking is that if a number is put in wrong the code would stop you with a message box to let you know the number was wrong and then when you ok the message box you would be back in the cell with the wrong number so you could put in a different number.
Using excel 2003
Thanks
Using excel 2003
Thanks
Code:
Option Explicit
Sub PutInNumbers()
Dim c As Range
Dim i As Integer
Dim j As Integer
Dim val1 As String
Range("C5").Select
Set c = ActiveCell
For i = 0 To 2
For j = 0 To 4
c.Offset(j, i).Select
val1 = InputBox("Please enter number", "Enter Number")
If val1 = "" Then
Exit Sub
Else
c.Offset(j, i).Value = val1
End If
Next j
Next i
End Sub