View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] youu917@gmail.com is offline
external usenet poster
 
Posts: 29
Default Looking for Help in modifying a code

I got a problem with my vba UserForm, here is the code:
Private Sub CommandButton1_Click()
Dim r As Variant
Dim C As Integer

C = TextBox1.Text

If IsNumeric(C) = False Then
MsgBox "Please enter an integer."

Else
For r = 1 To 700
If Cells(r, C).Value = "0" Then
Rows(r).Hidden = True
End If
Next
End If
End Sub

I'd like to make it when people key in a non-numeric character in the
textbox, it will promt out the message,however, when i Dim C As
Integer, once we key in a non numeric char it will cause a run time
error,since it is not an integer as i declared and if i Dim c As
Variant, the Cells(r,c) will not work as Cells() required an integer
inside.
Can anyone tell me how to solve the problem?