ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   When to use screenupdating? (https://www.excelbanter.com/excel-programming/318691-when-use-screenupdating.html)

augustus

When to use screenupdating?
 
hi,

I'm having some difficulty in getting the screenupdating to work.
Firstly, I have 1 small module, module1 (reside in sheet1), which call
another moduel, module2, and this also call another 4 mdoules, module3 to
module6 say.

With module3 (work on sheet3), and module5 (work on sheet4), both is
required to insert columns or rows to copy and add data, and it seem that I
must activate or select the sheet under either modules before I can add or
copy. Please let me know if there is another way? 'Cause I notice that the
moment a sheet, is Selected, the screenupdating stop working. I have declared
ScreenUpdating=Flase inside Module1, Module3 & Module5. But They don't work
in module 3 and 5.

Could someone pleaser let me the rule in using ScreenUpdating? Ie, if like
me, who has about 4 to 6 modules interrelated?

Sharad

When to use screenupdating?
 
Once screenupdating is set to false, it is not automatically turned on
after code is executed. You have to set it to true in your code, or you
have to quit excel and restart it.

When screenupdating is set to false, if you are selecting any ranges on
the sheet which was active just before setting screenupdating to false,
then you can see the on the screen that different ranges are being
selected.

Well to add rows / columns or data it is not neccessary to activate or
select the sheet.

See bellow example, run it with Sheet1 being active, it will add column,
row and data in to sheet2 without selecting or activating it.

With Worksheets("Sheet2")
With .Range("A5")
.EntireColumn.Insert
.Value = "xyz"
End With
With .Range("D5")
.EntireRow.Insert
.Value = "abc"
End With
End With
End Sub

Sharad


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

augustus

When to use screenupdating?
 
Hi Sharad,

Is it possible to insert or hide a column without selecting a sheet first?
Ie, could I insert a column in sheet3, while sheet 1 is activated?

thanks
Augustus


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com