Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default When code runs...worksheet acts a little strange

Hi
I'm using the following code below (with help form this group) to copy the
unique values in cell A8:A501 of the activeworksheet to cells A:14:A47 of
the Previous worksheet.
It's working good...but......after the user enters a value (presses the
enter key after entering data into a cell) on the Activeworksheet, the
worksheet knida flickers to the Previous worksheet and then back to the
Activeworksheet.
It is still working..it just looks a bit strange.
Is there a way to make this not happen?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim prevSheet As Worksheet

With Me

If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("WC Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If

.Unprotect Password:="test"

If Not Application.Intersect(Target, _
Range("A8:A501")) Is Nothing Then
prevSheet.Range("A13:A47").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A501"), prevSheet.Range("A13")
**** see below this code is in a standard module
End If

.Unprotect Password:="test"

'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlDescending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub



Public Sub gCopyUnique(rrngSource As Range, rrngDest As Range)
ActiveSheet.Unprotect Password:="test"
rrngSource.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=rrngDest, Unique:=True
ActiveSheet.Protect Password:="test", DrawingObjects:=True, Contents:=True,
Scenarios:=True

As Always...Thanks for your help!
Kimberly



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default When code runs...worksheet acts a little strange

Hi Kimberly

at the top of your code include the line
application.screenupdating = false

and at the end the line
application.screenupdating = true

this will stop the flickering

Cheers
JulieD

"KimberlyC" wrote in message
...
Hi
I'm using the following code below (with help form this group) to copy the
unique values in cell A8:A501 of the activeworksheet to cells A:14:A47 of
the Previous worksheet.
It's working good...but......after the user enters a value (presses the
enter key after entering data into a cell) on the Activeworksheet, the
worksheet knida flickers to the Previous worksheet and then back to the
Activeworksheet.
It is still working..it just looks a bit strange.
Is there a way to make this not happen?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim prevSheet As Worksheet

With Me

If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("WC Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If

.Unprotect Password:="test"

If Not Application.Intersect(Target, _
Range("A8:A501")) Is Nothing Then
prevSheet.Range("A13:A47").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A501"), prevSheet.Range("A13")
**** see below this code is in a standard module
End If

.Unprotect Password:="test"

'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlDescending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub



Public Sub gCopyUnique(rrngSource As Range, rrngDest As Range)
ActiveSheet.Unprotect Password:="test"
rrngSource.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=rrngDest, Unique:=True
ActiveSheet.Protect Password:="test", DrawingObjects:=True,
Contents:=True,
Scenarios:=True

As Always...Thanks for your help!
Kimberly





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default When code runs...worksheet acts a little strange

Thank you so much!!

Now it's prefect! :)

Thanks!
"JulieD" wrote in message
...
Hi Kimberly

at the top of your code include the line
application.screenupdating = false

and at the end the line
application.screenupdating = true

this will stop the flickering

Cheers
JulieD

"KimberlyC" wrote in message
...
Hi
I'm using the following code below (with help form this group) to copy

the
unique values in cell A8:A501 of the activeworksheet to cells A:14:A47

of
the Previous worksheet.
It's working good...but......after the user enters a value (presses the
enter key after entering data into a cell) on the Activeworksheet, the
worksheet knida flickers to the Previous worksheet and then back to the
Activeworksheet.
It is still working..it just looks a bit strange.
Is there a way to make this not happen?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim prevSheet As Worksheet

With Me

If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("WC Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If

.Unprotect Password:="test"

If Not Application.Intersect(Target, _
Range("A8:A501")) Is Nothing Then
prevSheet.Range("A13:A47").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A501"), prevSheet.Range("A13")
**** see below this code is in a standard module
End If

.Unprotect Password:="test"

'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlDescending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub



Public Sub gCopyUnique(rrngSource As Range, rrngDest As Range)
ActiveSheet.Unprotect Password:="test"
rrngSource.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=rrngDest, Unique:=True
ActiveSheet.Protect Password:="test", DrawingObjects:=True,
Contents:=True,
Scenarios:=True

As Always...Thanks for your help!
Kimberly







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default When code runs...worksheet acts a little strange

you're welcome and thanks for the feedback

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"KimberlyC" wrote in message
...
Thank you so much!!

Now it's prefect! :)

Thanks!
"JulieD" wrote in message
...
Hi Kimberly

at the top of your code include the line
application.screenupdating = false

and at the end the line
application.screenupdating = true

this will stop the flickering

Cheers
JulieD

"KimberlyC" wrote in message
...
Hi
I'm using the following code below (with help form this group) to copy

the
unique values in cell A8:A501 of the activeworksheet to cells A:14:A47

of
the Previous worksheet.
It's working good...but......after the user enters a value (presses the
enter key after entering data into a cell) on the Activeworksheet, the
worksheet knida flickers to the Previous worksheet and then back to the
Activeworksheet.
It is still working..it just looks a bit strange.
Is there a way to make this not happen?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim prevSheet As Worksheet

With Me

If .Index = 1 Then
MsgBox "No sheets to the left"
Set prevSheet = Worksheets("WC Adjustments")
Else
Set prevSheet = Worksheets(.Index - 1)
End If

.Unprotect Password:="test"

If Not Application.Intersect(Target, _
Range("A8:A501")) Is Nothing Then
prevSheet.Range("A13:A47").ClearContents
prevSheet.Unprotect Password:="test"
gCopyUnique Range("A8:A501"), prevSheet.Range("A13")
**** see below this code is in a standard module
End If

.Unprotect Password:="test"

'Range("R16:R51").Select
prevSheet.Unprotect Password:="test"
prevSheet.Range("A13:A47").Sort , _
Key1:=prevSheet.Range("A13"), _
Order1:=xlDescending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End With
prevSheet.Protect Password:="test", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub



Public Sub gCopyUnique(rrngSource As Range, rrngDest As Range)
ActiveSheet.Unprotect Password:="test"
rrngSource.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=rrngDest, Unique:=True
ActiveSheet.Protect Password:="test", DrawingObjects:=True,
Contents:=True,
Scenarios:=True

As Always...Thanks for your help!
Kimberly









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code runs...need spaces ........ Wanna Learn Excel Discussion (Misc queries) 2 January 20th 09 12:44 PM
Worksheet acts like its protected but it's not I can''t get sort to work Excel Discussion (Misc queries) 1 August 27th 07 05:16 AM
VBA code that only runs when a worksheet is active Paul James[_3_] Excel Programming 4 December 11th 03 01:05 AM
Code runs every other time Mike Waldron Excel Programming 1 September 27th 03 03:54 PM
How to keep from going dizzy when my code runs TBA[_2_] Excel Programming 3 September 23rd 03 11:33 PM


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"