PC Review


Reply
Thread Tools Rate Thread

'Application.ScreenUpdating = False' isn't working

 
 
Dan R.
Guest
Posts: n/a
 
      1st Mar 2007
This code just copies values from the active ws to another wb and then
pastes values from the wb back to the active ws. It works fine but I
want to hide the wb and stop the screen updating until the code is
complete... How can I do this?


Sub Populate_H6()
Dim ws As Worksheet
Dim wb As Workbook
Dim rng As Range
Dim rCell As Range

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Open("A:\Lookup.xls")

With ws
Set rng = .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 2).End(xlUp))
End With

For Each rCell In rng.Cells
Select Case rCell.Value
Case "TiM"
rCell.Offset(0, 1).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 1)
rCell.Offset(0, 2).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 2)
wb.Worksheets(13).Range(rCell.Address) _
.Offset(3, 5).Copy ws.Range(rCell.Address).Offset(0, 3)
Case "MiM"
rCell.Offset(0, 1).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 7)
rCell.Offset(0, 2).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 8)
wb.Worksheets(13).Range(rCell.Address) _
.Offset(3, 11).Copy ws.Range(rCell.Address).Offset(0, 3)
Case "WiM"
rCell.Offset(0, 1).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 13)
rCell.Offset(0, 2).Copy wb.Worksheets(13) _
.Range(rCell.Address).Offset(3, 14)
wb.Worksheets(13).Range(rCell.Address) _
.Offset(3, 17).Copy ws.Range(rCell.Address).Offset(0, 3)
End Select
Next

With ws
ws.Columns("D").ClearFormats
ws.Columns("D").AutoFit
End With

wb.Close savechanges:=False

Application.ScreenUpdating = True

End Sub


Thank You,
-- Dan

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      1st Mar 2007
It looks like you have the .screenupdating lines in the appropriate spots.

Any chance that you have some event (workbook_Open in lookup.xls???) that turns
the screenupdating back on?

If yes, you could turn off screenupdating right after you open lookup.xls--or
you could disable events before you open that file:

application.enableevents = false
set wb = workbooks.open(....
application.enableevents = true

You could have events that fire when you're making a selection change or a
worksheet change, too. You may want to spend some time isolating where the
problem occurs.

By the way, I wouldn't open a file that's on my floppy. I'd copy it to my
harddrive and open it from there.

"Dan R." wrote:
>
> This code just copies values from the active ws to another wb and then
> pastes values from the wb back to the active ws. It works fine but I
> want to hide the wb and stop the screen updating until the code is
> complete... How can I do this?
>
> Sub Populate_H6()
> Dim ws As Worksheet
> Dim wb As Workbook
> Dim rng As Range
> Dim rCell As Range
>
> Application.ScreenUpdating = False
>
> Set ws = ActiveSheet
> Set wb = Workbooks.Open("A:\Lookup.xls")
>
> With ws
> Set rng = .Range(.Cells(1, 1), _
> .Cells(.Rows.Count, 2).End(xlUp))
> End With
>
> For Each rCell In rng.Cells
> Select Case rCell.Value
> Case "TiM"
> rCell.Offset(0, 1).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 1)
> rCell.Offset(0, 2).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 2)
> wb.Worksheets(13).Range(rCell.Address) _
> .Offset(3, 5).Copy ws.Range(rCell.Address).Offset(0, 3)
> Case "MiM"
> rCell.Offset(0, 1).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 7)
> rCell.Offset(0, 2).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 8)
> wb.Worksheets(13).Range(rCell.Address) _
> .Offset(3, 11).Copy ws.Range(rCell.Address).Offset(0, 3)
> Case "WiM"
> rCell.Offset(0, 1).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 13)
> rCell.Offset(0, 2).Copy wb.Worksheets(13) _
> .Range(rCell.Address).Offset(3, 14)
> wb.Worksheets(13).Range(rCell.Address) _
> .Offset(3, 17).Copy ws.Range(rCell.Address).Offset(0, 3)
> End Select
> Next
>
> With ws
> ws.Columns("D").ClearFormats
> ws.Columns("D").AutoFit
> End With
>
> wb.Close savechanges:=False
>
> Application.ScreenUpdating = True
>
> End Sub
>
> Thank You,
> -- Dan


--

Dave Peterson
 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      1st Mar 2007
Oh I know, I mapped a network drive on A: for some odd reason. But yes
you're right I do have a worksheet_change event on the Lookup sheet.
This is probably a stupid question but if I turn off screenupdating
after I open Lookup then it's still going to show it open it correct?
Or do I have to turn it off both before and after I open Lookup?

Thanks Dave,
-- Dan

 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      1st Mar 2007
nevermind, you're exactly right... that worked. I hate to push my luck
but could you please give me some insight as to how to display as
progress bar while the code is running?

Thanks,
-- Dan

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      1st Mar 2007
That first section of code is pretty small and doesn't do any screenupdating
anyway. You're not gaining too much by turning off screenupdating before the
..open line.

And if you turn off screenupdating after you open lookup.xls, then it'll show
up. But you could activate the other workbook right after you open the file,
then turn off screenupdating--or turn off the events.

Set ws = ActiveSheet
Set wb = Workbooks.Open("A:\Lookup.xls")

ws.parent.activate
Application.ScreenUpdating = False

With ws
Set rng = .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 2).End(xlUp))
End With

=====
might be ok.


"Dan R." wrote:
>
> Oh I know, I mapped a network drive on A: for some odd reason. But yes
> you're right I do have a worksheet_change event on the Lookup sheet.
> This is probably a stupid question but if I turn off screenupdating
> after I open Lookup then it's still going to show it open it correct?
> Or do I have to turn it off both before and after I open Lookup?
>
> Thanks Dave,
> -- Dan


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      1st Mar 2007
I'd use the statusbar at the bottom.

Application.statusbar = "Processing: " & mycell.row & " at: " & now
Inside the loop

then at the end, give the statusbar back to excel:

application.statusbar = false

=====
But if you want a statusbar, you can look at John Walkenbach's site:
http://www.j-walk.com/ss/excel/tips/tip34.htm



"Dan R." wrote:
>
> nevermind, you're exactly right... that worked. I hate to push my luck
> but could you please give me some insight as to how to display as
> progress bar while the code is running?
>
> Thanks,
> -- Dan


--

Dave Peterson
 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      2nd Mar 2007
Works great Dave.

Thank You,
-- Dan

 
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
application.screenupdating = false not working =?Utf-8?B?U2FicmU=?= Microsoft Excel Programming 11 13th Apr 2007 07:46 PM
Application.ScreenUpdating = False Not Working =?Utf-8?B?U2hlbGx5?= Microsoft Excel Programming 3 28th Mar 2007 01:53 AM
Screen still changes. Why ? (Application.Screenupdating = False not working Coza Microsoft Excel Programming 1 21st Mar 2007 03:47 AM
Using the Application.ScreenUpdating = False? Susan Hayes Microsoft Excel Programming 1 29th Jan 2005 02:16 PM
ActiveWorkbook.Application.ScreenUpdating = False Not Working DoctorV Microsoft Excel Discussion 1 25th Aug 2004 08:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 PM.