Hello all
I am activating the code below from a command button on a userform. The background to the code is that the user selects a cell then right clicks and a 'Move cells' option appears. On clicking it a userform appears and the user selects where the cells can be moved to. There is a series of restrictions on whether the cells can be moved and these are built into the code.
My problems is simply the the screen flickers. I have been inserting application.screenupdating= true and application.screenupdating = true in every combination but can get it. Is there a rule about where to inut them?
Can anyone help. thank you
I am activating the code below from a command button on a userform. The background to the code is that the user selects a cell then right clicks and a 'Move cells' option appears. On clicking it a userform appears and the user selects where the cells can be moved to. There is a series of restrictions on whether the cells can be moved and these are built into the code.
My problems is simply the the screen flickers. I have been inserting application.screenupdating= true and application.screenupdating = true in every combination but can get it. Is there a rule about where to inut them?
Can anyone help. thank you
Code:
Dim x, y As Double, c As Range
Dim w As Range
Dim mycheck As String
Dim mycheck1 As String
Dim mycheck2 As String
Set c = Selection
x = UserForm2.ComboBox1.Value
If x = False Then Exit Sub
Set w = ActiveSheet.Columns(9).Find(What:=x, LookIn:=xlFormulas, LookAt:=xlWhole)
v = w.Offset(0, 1).Value
If UserForm2.ComboBox1.Value = "" Then
MsgBox ("x")
ActiveSheet.Protect ("jweir")
Exit Sub
Else
If c.Offset(0, 2).Value = "" Then
MsgBox ("x")
UserForm2.ComboBox1 = ""
Exit Sub
Else
If w.Offset(0, 2).Value <> "" Then
MsgBox ("x")
UserForm2.ComboBox1 = ""
Exit Sub
Else
If w.Offset(0, -6) <> c.Offset(0, -6) Then
MsgBox ("x")
UserForm2.ComboBox1 = ""
ActiveSheet.Protect ("jweir")
Exit Sub
Else
If w.Offset(0, 2) = "" And c.Offset(0, 1) <> w.Offset(0, 1) Then
mycheck1 = MsgBox("x?", vbYesNo)
If mycheck1 = vbNo Then
UserForm2.ComboBox1 = ""
Exit Sub
Else
w.Offset(0, 2).Value = c.Offset(0, 2).Value
w.Offset(0, 3).Value = c.Offset(0, 3).Value
w.Offset(0, 7).Value = c.Offset(0, 7).Value
c.Offset(0, 2).Value = ""
c.Offset(0, 3).Value = ""
c.Offset(0, 7).Value = ""
UserForm2.ComboBox1 = ""
UserForm2.Hide
End If
Else
If w.Offset(0, 12).Value = "x" Then
mycheck = MsgBox("x?", vbYesNo)
If mycheck = vbNo Then
UserForm2.ComboBox1 = ""
Exit Sub
Else
w.Offset(0, 2).Value = c.Offset(0, 2).Value
w.Offset(0, 3).Value = c.Offset(0, 3).Value
w.Offset(0, 7).Value = c.Offset(0, 7).Value
c.Offset(0, 2).Value = ""
c.Offset(0, 3).Value = ""
c.Offset(0, 7).Value = ""
UserForm2.ComboBox1 = ""
UserForm2.Hide
End If
Else
If w.Offset(0, -8) <> c.Offset(0, -8) Then
mycheck2 = MsgBox("x?", vbYesNo)
If mycheck2 = vbNo Then
UserForm2.ComboBox1 = ""
Exit Sub
Else
w.Offset(0, 2).Value = c.Offset(0, 2).Value
w.Offset(0, 3).Value = c.Offset(0, 3).Value
w.Offset(0, 7).Value = c.Offset(0, 7).Value
c.Offset(0, 2).Value = ""
c.Offset(0, 3).Value = ""
c.Offset(0, 7).Value = ""
UserForm2.ComboBox1 = ""
UserForm2.Hide
End If
Else
w.Offset(0, 2).Value = c.Offset(0, 2).Value
w.Offset(0, 3).Value = c.Offset(0, 3).Value
w.Offset(0, 7).Value = c.Offset(0, 7).Value
c.Offset(0, 2).Value = ""
c.Offset(0, 3).Value = ""
c.Offset(0, 7).Value = ""
UserForm2.ComboBox1 = ""
UserForm2.Hide
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub CommandButton2_Click()
UserForm2.Hide
End Sub
Last edited by a moderator: