ScreenUpdating Question

J

Joel Mills

I have been successful in keeping other macros from creating a flashing
screen upon running them, but the following two macros flicker when
switching between worksheets even though I have added Application Screen
updating = False as the first line and = True in the last line of the code.
Does this happen because I am activating the Worksheets? If so how can I
modify the code to ungroup and regroup the shapes to allow input from the
users to change the text? Also any help in cleaning up the code which was
modified after recording the macro would be appreciated.

Joel

Sub Regroup()
Application.ScreenUpdating = False
'This Regroups the Curve Header
Sheets("Curve").Activate
ActiveSheet.Shapes.Range(Array("Curve Line No. 1", "Curve Line No. 2",
_
"Curve Line No. 3", "Curve Line No. 4")).Select
Selection.ShapeRange.Regroup.Select
Selection.Name = "Curve Header"
'This Regroups the Left Footer
ActiveSheet.Shapes.Range(Array("Left Footer L1", "Left Footer L2", _
"Left Footer L3", "Left Footer L4")).Select
Selection.ShapeRange.Regroup.Select
Selection.Name = "Left Footer"
'This Regroups the Right Footer
ActiveSheet.Shapes.Range(Array("Right Footer L1", "Right Footer L2", _
"Right Footer L3", "Right Footer L4")).Select
Selection.ShapeRange.Regroup.Select
Selection.Name = "Right Footer"
'This Regroups the Histogram Title
Sheets("Histogram").Select
ActiveSheet.Shapes.Range(Array("Histogram L1", "Histogram L2", _
"Histogram L3", "Histogram L4")).Select
Selection.ShapeRange.Regroup.Select
Selection.Name = "Histogram Title"
Sheets("Curve").Activate
Application.ScreenUpdating = True
End Sub

Sub Ungroup()
'
Application.ScreenUpdating = False
' Ungroup Macro
Worksheets("Curve").Activate
ActiveSheet.Shapes.Range(Array("Curve Header", "Left Footer", "Right
Footer")). _
Select
Selection.ShapeRange.Ungroup.Select
Sheets("Histogram").Activate
ActiveChart.Shapes("Histogram Title").Select
Selection.ShapeRange.Ungroup.Select
Worksheets("Curve").Activate
Application.ScreenUpdating = True
End Sub
 
G

Guest

Hi Joel,

Consider using object variables as I've demonstrated below. With object
variables you don't need to .Select the shapes, which in turn means you don't
need to activate the worksheet that contains them.

'This Regroups the Curve Header
Dim ShpRng As ShapeRange
Set ShpRng = Sheets("Curve").Shapes.Range(Array( _
"Curve Line No. 1", _
"Curve Line No. 2", _
"Curve Line No. 3", _
"Curve Line No. 4"))
ShpRng.Group
ShpRng.Name = "Curve Header"


Regards,
Vic Eldridge
 
J

Joel Mills

Vic,

I revised my code as you suggested and this fixed the flickering (changing
between worksheets).
My project looks professional now thanks to your help.

Joel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top