I have code that checks for gaps and fills them in with sequential numeric data.
I'm trying to introduce a message box if the user tries activating the code without the selection being numeric data and can't quite get my head around it. If not numeric data, show message and exit sub. If numeric data, continue to process without a message.
VBA Code:
Sub AutoFill()
Dim R&, F%
R = ActiveCell.Row
Do
F = 1
R = R + 1
If IsEmpty(Cells(R, 1)) Then F = 0: Cells(R, 1) = Cells(R - 1, 1)
If IsEmpty(Cells(R, 2)) Then F = 0: Cells(R, 2) = Cells(R - 1, 2) + 1
Loop Until F
End Sub
I'm trying to introduce a message box if the user tries activating the code without the selection being numeric data and can't quite get my head around it. If not numeric data, show message and exit sub. If numeric data, continue to process without a message.
VBA Code:
Sub AutoFill()
Dim R&, F%
R = ActiveCell.Row
Do
F = 1
R = R + 1
If Not IsNumeric Then
MsgBox ("The selection is text, this keyboard shortcut will only work with numbers."), vbOKOnly + vbInformation, "Shortcut Information"
Exit Sub
End If
Else
If IsEmpty(Cells(R, 1)) Then F = 0: Cells(R, 1) = Cells(R - 1, 1)
If IsEmpty(Cells(R, 2)) Then F = 0: Cells(R, 2) = Cells(R - 1, 2) + 1
Loop Until F
End Sub