Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VBA: sheet in background

All gurus,
until now I open an excel sheet before the macro read from it, or create an
excel sheet before the macro write to it as follows:

Workbooks.Open FileName:=MyFileName
Sheets(MySheet).Select
(read from the sheet......)

or

Workbooks.Add
(write to it ......)

This way I see each sheet opened or created, a cell is written, ......
(Maybe this causes the macro running very slowly?)
Is it possible to read from or write to an excel sheet without displaying it
in the excel window? Just as, if we open a text file and do reading or
writing, we don't need to open it with notepad. Everything is done in the
background.
Many thanks in advance!

w.wang
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default VBA: sheet in background


Wang wrote:

All gurus,
until now I open an excel sheet before the macro read from it, or create an
excel sheet before the macro write to it as follows:

Workbooks.Open FileName:=MyFileName
Sheets(MySheet).Select
(read from the sheet......)

or

Workbooks.Add
(write to it ......)

This way I see each sheet opened or created, a cell is written, ......
(Maybe this causes the macro running very slowly?)
Is it possible to read from or write to an excel sheet without displaying it
in the excel window? Just as, if we open a text file and do reading or
writing, we don't need to open it with notepad. Everything is done in the
background.
Many thanks in advance!

w.wang


Application.Screenupdating = False

at the start of the code should hide it.

Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default VBA: sheet in background

I probably shouldn't respond to a message that starts "All gurus", but
my judgement is still clouded by lack of coffee...

1) Try Application.ScreeenUpdating = False at the start of your macro
and Application.ScreenUpdating = True at the end.

2) It is seldom necessary to select an object before you manipulate it.
So for example, if you want the value in A1 in MySheet rather than
writing

Sheets(MySheet).Select
x = Range("A1").Value

Just write

x = Sheets(MySheet).Range("A1").Value

If you need to get a lot of values from MySheet then it might make
sense to first activate it, but even then you could consider using the
With ... End With construct.

Hopefully the real gurus will be waking up soon

-John Coleman

Wang wrote:
All gurus,
until now I open an excel sheet before the macro read from it, or create an
excel sheet before the macro write to it as follows:

Workbooks.Open FileName:=MyFileName
Sheets(MySheet).Select
(read from the sheet......)

or

Workbooks.Add
(write to it ......)

This way I see each sheet opened or created, a cell is written, ......
(Maybe this causes the macro running very slowly?)
Is it possible to read from or write to an excel sheet without displaying it
in the excel window? Just as, if we open a text file and do reading or
writing, we don't need to open it with notepad. Everything is done in the
background.
Many thanks in advance!

w.wang


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default VBA: sheet in background

You don't consider yourself as a guru, but my opinion is that you replied to
the question at a level of a guru. Anyway your explanation helps me a great
deal. Thank you very much!

w.wang

"John Coleman" wrote:

I probably shouldn't respond to a message that starts "All gurus", but
my judgement is still clouded by lack of coffee...

1) Try Application.ScreeenUpdating = False at the start of your macro
and Application.ScreenUpdating = True at the end.

2) It is seldom necessary to select an object before you manipulate it.
So for example, if you want the value in A1 in MySheet rather than
writing

Sheets(MySheet).Select
x = Range("A1").Value

Just write

x = Sheets(MySheet).Range("A1").Value

If you need to get a lot of values from MySheet then it might make
sense to first activate it, but even then you could consider using the
With ... End With construct.

Hopefully the real gurus will be waking up soon

-John Coleman

Wang wrote:
All gurus,
until now I open an excel sheet before the macro read from it, or create an
excel sheet before the macro write to it as follows:

Workbooks.Open FileName:=MyFileName
Sheets(MySheet).Select
(read from the sheet......)

or

Workbooks.Add
(write to it ......)

This way I see each sheet opened or created, a cell is written, ......
(Maybe this causes the macro running very slowly?)
Is it possible to read from or write to an excel sheet without displaying it
in the excel window? Just as, if we open a text file and do reading or
writing, we don't need to open it with notepad. Everything is done in the
background.
Many thanks in advance!

w.wang



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
How to set background on the Excel sheet Vatana Excel Discussion (Misc queries) 2 December 18th 07 08:40 PM
Sheet Background does not print Corey Excel Worksheet Functions 3 July 26th 07 05:53 AM
Don't want to tile sheet background Dene New Users to Excel 1 November 2nd 06 08:16 PM
Sheet Background helmekki[_85_] Excel Programming 4 August 1st 05 05:30 AM
Sheet Background Color Bill Helbron Excel Discussion (Misc queries) 2 April 14th 05 04:31 PM


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

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"