Thread: Do Loop Until
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Do Loop Until

I just check and exit when I want:

Option Explicit
Sub AddLoadCase()
Dim mynum As String
Dim nm As Name
Do

mynum = InputBox("ENTER Load Case Name", "Load Case Namer")
If mynum = "" Then
Exit Sub
End If

Set nm = Nothing
On Error Resume Next
Set nm = ThisWorkbook.Names(mynum)
On Error GoTo 0
If nm Is Nothing Then
Exit Do
else
MsgBox "Name '" & mynum & _
"' already exists. Please Choose Anther 'name'!"
End If
Loop

Range("AD2:AK4").Copy
Range("B1000").End(xlUp).Offset(3, 0).PasteSpecial
Range("B1000").End(xlUp).Offset(0, 0).Select
Range("B1000").End(xlUp).Offset(0, 0).Value = mynum

End Sub

Kevin O'Neill wrote:

Not quite working.

Isn't there a way to set bookmarks in your actual code, and then jump
back to them?


--

Dave Peterson