View Single Post
  #20   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default IsBlank() in VBA code?

I'm not sure how this code is run, but this may get you closer.

And I'm gonna guess that you want to use this userform to populate the
activecell--not just F11.

'select the cell to start

with activecell
if trim(.value) = "" then
userform1.show
end if
end with

Then I created a userform that has a label, a textbox and two commandbuttons.

This is the code behind the userform:

Option Explicit
Private Sub CommandButton1_Click()
ActiveCell.Value = Trim(Me.TextBox1.Text)
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
Me.CommandButton1.Enabled _
= CBool(Len(Trim(Me.TextBox1.Text)) 0)
End Sub
Private Sub UserForm_Initialize()

Me.Caption = "Enter a value"

With Me.Label1
.Caption = "Please enter a value for: " _
& ActiveCell.Address(0, 0)
.ForeColor = vbRed
End With

With Me.CommandButton1
.Caption = "Ok"
.Default = True
.Enabled = False
End With

With Me.CommandButton2
.Caption = "Cancel"
.Cancel = True
.TakeFocusOnClick = False
End With

End Sub

The Ok button should only be "clickable" if there's something (non-space) in
that textbox.

Debra Dalgleish shares lots of good info about userforms:
http://contextures.com/xlUserForm01.html




Jim McCaffrey wrote:

Ronald - I wonder if you could help me with one other thing. I have a
couple required fields that contain several lines of text and I'm trying
to make the Application.InputBox bigger, but I can't find anything on
changing the size. I started to create a user form, but I keep getting a
"mismatch" error. I also added a Do Loop statement so that the user has
to enter something in the field.

Thanks again for your help.
Jim

ColumnCCheck5:
If VBA.Trim(Worksheets("DLR").Range("F11").Text) = "" Then
Range("F11").Select
MsgBox "Work Performed field is empty. Click OK to return to
worksheet to update."

Do
' Range("F11").Value2 = UserForm1.Show

Range("F11").Value2 = Application.InputBox("Work Performed field is
empty. Enter the Work Performed that day in this field. You can enter a
little bit of information then go back later and add more. ", "Work
Performed")

Loop Until Range("C8").Value2 < "False"
GoTo ColumnCCheck5
End If

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson