View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
michdenis michdenis is offline
external usenet poster
 
Posts: 135
Default MsgBox. problem to continue the macro

Hi,

Dim iCtr As Integer

If MsgBox("This serialnumber allready exist! " & _
" Press OK if you want to continue ", vbOKCancel) = vbCancel Then
Exit Sub
Else
iCtr = ComboBox1.Value
Range("B" & CStr(iCtr + 3)) = Me.ComboBox2
Range("C" & CStr(iCtr + 3)) = Me.TextBox1
Range("D" & CStr(iCtr + 3)) = Me.TextBox2
Range("E" & CStr(iCtr + 3)) = Me.TextBox3
Range("F" & CStr(iCtr + 3)) = Me.TextBox4
Range("G" & CStr(iCtr + 3)) = Me.TextBox5
Range("H" & CStr(iCtr + 3)) = Me.Comboday & Me.Combomonth & Me.Comboyear

If TextBox1.Text = "" Then Range("B" & CStr(iCtr + 3)).ClearContents
If TextBox1.Text = "" Then Range("C" & CStr(iCtr + 3)).ClearContents
End If




"Axel" a écrit dans le message de groupe de discussion :
...
Hi!
Am not able to make the macro continue after an msgbox has been displayed.

This msgbox come as an warning if one cell in the column, contains the same
contents as the textbox 1 is going to insert to the same or another cell in
the column range.

I want the user to be able to do changes in the textboxes on this userform,
after the msgbox has been displayed, but it only work when it's not duplicate
contents in the range

Any suggestions?


Application.ScreenUpdating = False
Dim myStr As String
myStr = TextBox1.Text
If Application.CountIf(v, myStr) 0 Then
ans = MsgBox("This serialnumber allready exist! Press OK if you want to
continue", vbOKCancel)
If ans = vbCancel Then Exit Sub
Else
Dim iCtr As Integer
iCtr = ComboBox1.Value
Range("B" & CStr(iCtr + 3)) = Me.ComboBox2
Range("C" & CStr(iCtr + 3)) = Me.TextBox1
Range("D" & CStr(iCtr + 3)) = Me.TextBox2
Range("E" & CStr(iCtr + 3)) = Me.TextBox3
Range("F" & CStr(iCtr + 3)) = Me.TextBox4
Range("G" & CStr(iCtr + 3)) = Me.TextBox5
Range("H" & CStr(iCtr + 3)) = Me.Comboday & Me.Combomonth & Me.Comboyear

If TextBox1.Text = "" Then Range("B" & CStr(iCtr + 3)).ClearContents
If TextBox1.Text = "" Then Range("C" & CStr(iCtr + 3)).ClearContents
End If
--
Axel
Copy & paste developer