Trapping blanks

C

Curt

Received this code want to idenify empty cells and return to sheet if
vbyes/no yes. I am missing something because it goes on and runs code instead
of returning to worksheet for completion. Not sure what to add.
Thanks

Dim Blanks As VbMsgBoxResult
Dim LastRow As Long
Dim myR As Range

With Worksheets("MailD")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
On Error GoTo NoBlanks
Set myR = .Range("A2:F2").Resize(LastRow -
4).SpecialCells(xlCellTypeBlanks)
Blanks = MsgBox("Do you want to complete blanks?", vbYesNo)
If Blanks = vbYes Then
myR.Select
End If
NoBlanks:
End With
 
J

Jim Cone

Maybe this...
If Blanks = vbYes Then
myR.Select
End If

Should be...
If Blanks = vbYes Then
myR.Select
Exit Sub
End If
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Curt"
wrote in message
Received this code want to idenify empty cells and return to sheet if
vbyes/no yes. I am missing something because it goes on and runs code instead
of returning to worksheet for completion. Not sure what to add.
Thanks

Dim Blanks As VbMsgBoxResult
Dim LastRow As Long
Dim myR As Range
With Worksheets("MailD")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
On Error GoTo NoBlanks
Set myR = .Range("A2:F2").Resize(LastRow -
4).SpecialCells(xlCellTypeBlanks)
Blanks = MsgBox("Do you want to complete blanks?", vbYesNo)
If Blanks = vbYes Then
myR.Select
End If
NoBlanks:
End With
 
C

Curt

Made the change and all I need to do now is hide userform. Was makeing
change in wrong place. first time around.
Thanks for input.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top