Using macro to add data in specific cell within a table

K

Kelly n español

Is something like this what you are looking for?


Code
-------------------
Sub Mark_with_an_X()

continue = True

Do While continue = True

Do
Repeat = False
myColumn = InputBox("Enter a column letter from A to Z:", "Choose a column", "A")

'******CODE BELOW TO VALIDATE USER INPUT*************

If myColumn = "" Then End

If Len(Trim(myColumn)) <> 1 Then
MsgBox "You must enter exactly ONE letter."
Repeat = True
End If

If CBool((Asc(myColumn) < 91 And Asc(myColumn) > 64) Or (Asc(myColumn) < 123 And Asc(myColumn) > 96)) = False Then
MsgBox "You must enter a letter of the alphabet. No symbols or numbers."
Repeat = True
End If

Loop While Repeat = True

'*********DONE VALIDATING THE COLUMN LETTER INPUT************

Do
Repeat = False
myRow = InputBox("Enter a row number from 1 to 99:", "Choose a row", "1")

'******CODE BELOW TO VALIDATE ROW INPUT********************

If myRow = "" Then End

If Len(Trim(myRow)) > 2 Or Len(Trim(myRow)) < 1 Or Trim(myRow) = "0" Then
MsgBox "Your input is invalid. MUST BE a number from 1 to 99"
Repeat = True
End If

If CByte(myRow) < 1 Or CByte(myRow) > 99 Then
MsgBox "Your input is invalid. MUST BE a number from 1 to 99"
Repeat = True
End If

Loop While Repeat = True

'******DONE VALIDATING ROW NUMBER INPUT*************************

'****PLACE THE X-MARK NOW*****************************

myCellAddress = myColumn & myRow

Range(myCellAddress).Value = "X"

'*********ASK USER WHETHER TO CONTINUE OR QUIT****************

userDecision = MsgBox("Would you like to mark another cell?", vbOKCancel)

If userDecision <> 1 Then continue = False

Loop

End Sub
 
Top