PC Review


Reply
Thread Tools Rate Thread

can't move UserForm with the mouse

 
 
Axel
Guest
Posts: n/a
 
      1st Jul 2007
I have a userform with comcobox, two textbox and some buttons.
If I run this macro (from button in userform) shown below, and then try
to move the UserForm with the mouse, the UserForm getting spread all
over the screen(Following the mouse).Looks like it's copying itself for
every movment.
Any Suggestion why? Everything works fine, but is not possible to look
at the cells behind the userform, by moving it.


Private Sub CommandButton3_Click()
ActiveSheet.Unprotect Password:=""
Application.ScreenUpdating = False

Dim c As range
Set c = ActiveCell
For Each c In ActiveSheet.range("B4:B53")
If Not IsEmpty(c) Then GoTo line1 Else GoTo line2
line1:
Next c
line2:
ComboBox1.Value = c.Offset(0, -1).Value
ComboBox1.SetFocus

ActiveSheet.Protect Password:="", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      1st Jul 2007
This is normally what happens when screen updating is set to false. Your code
sets screen updating to false and does not reset it back to true. Suggested
rewrite:

Private Sub CommandButton3_Click()
Dim c As Range
ActiveSheet.Unprotect
Application.ScreenUpdating = False
For Each c In Range("B4:B53")
If IsEmpty(c) Then Exit For
Next c
ComboBox1.Value = c.Offset(0, -1).Value
ComboBox1.SetFocus
Application.ScreenUpdating = True
ActiveSheet.Protect
End Sub

"Axel" wrote:

> I have a userform with comcobox, two textbox and some buttons.
> If I run this macro (from button in userform) shown below, and then try
> to move the UserForm with the mouse, the UserForm getting spread all
> over the screen(Following the mouse).Looks like it's copying itself for
> every movment.
> Any Suggestion why? Everything works fine, but is not possible to look
> at the cells behind the userform, by moving it.
>
>
> Private Sub CommandButton3_Click()
> ActiveSheet.Unprotect Password:=""
> Application.ScreenUpdating = False
>
> Dim c As range
> Set c = ActiveCell
> For Each c In ActiveSheet.range("B4:B53")
> If Not IsEmpty(c) Then GoTo line1 Else GoTo line2
> line1:
> Next c
> line2:
> ComboBox1.Value = c.Offset(0, -1).Value
> ComboBox1.SetFocus
>
> ActiveSheet.Protect Password:="", DrawingObjects:=True, _
> Contents:=True, Scenarios:=True
> End Sub
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Axel
Guest
Posts: n/a
 
      1st Jul 2007


Thank you very much Greg!

That worked!

Aksel

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Mouse Move the mouse pointer fick when using Image Victor Torres Microsoft Access Form Coding 11 26th Apr 2009 05:34 AM
Move cursor to textbox in a userform jgmiddel Microsoft Excel Programming 5 29th Mar 2006 02:55 PM
Windows Media Player causes Mouse Pointer to freeze on screen (can still move mouse) zanthras Support 10 16th Feb 2006 02:46 AM
Disabling Move for Userform =?Utf-8?B?RnJhbmNpcyBBbmc=?= Microsoft Excel Programming 2 4th Jan 2005 10:53 AM
How to Move the Mouse or How to unvisible the Mouse Benjamin Wagner Microsoft Dot NET Compact Framework 3 31st Dec 2003 05:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:02 AM.