Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.vc.mfc,microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Alternatives to VBA in Excel

Hi,
excuse my cross-posting, but I do not know which NG is the appropriate for
my problem.
I wrote an Excel-Macro in VBA which reads a text file, interprets this file
and then does in Excel what has to be done: format cells, put values to it,
storing files, inserting worksheets etc.
This works well, as designed, but is not very fast.
So I look for a way to increase speed.
I have Visual C++ 6 in Visual Studio. Can I rewrite my macro in Visual C++
so that it gets faster? If yes, where do I find "easy to understand"
descriptions how to do this? What do I need additionally?
TIA
Thomas Kregeloh


  #2   Report Post  
Posted to microsoft.public.vc.mfc,microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Alternatives to VBA in Excel

Do you use Select in your vba code? Does the screen flash all over the
place while your code is running?
If so, you might be able to dramatically increase the speed of your macro by
not using select or by setting ScreenUpdating = False and turning
calculation off.

--
Regards,
Tom Ogilvy

"Thomas Kregeloh" wrote in message
...
Hi,
excuse my cross-posting, but I do not know which NG is the appropriate for
my problem.
I wrote an Excel-Macro in VBA which reads a text file, interprets this

file
and then does in Excel what has to be done: format cells, put values to

it,
storing files, inserting worksheets etc.
This works well, as designed, but is not very fast.
So I look for a way to increase speed.
I have Visual C++ 6 in Visual Studio. Can I rewrite my macro in Visual C++
so that it gets faster? If yes, where do I find "easy to understand"
descriptions how to do this? What do I need additionally?
TIA
Thomas Kregeloh




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Alternatives to VBA in Excel

Hi Tom,
yes, I use select. I have disabled the screen-update in order to increase
speed.
What's the problem about "select"? I did not yet think about turning
calculation off.
Regards
Thomas


"Tom Ogilvy" schrieb im Newsbeitrag
...
Do you use Select in your vba code? Does the screen flash all over the
place while your code is running?
If so, you might be able to dramatically increase the speed of your macro

by
not using select or by setting ScreenUpdating = False and turning
calculation off.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Alternatives to VBA in Excel

The problem with select is that it is slow, and if there is a lot of it
going on, it can make quite a performance difference. If on top of that you
move between worksheets, that compounds the problem. For instance, this is
the sort of code that the macro recorder creates

Range("A1").Select
Selection.Value = "abc"

can be more efficiently written as

Range("A1").Value = "abc"

The amount of work removed here, and the CPU cycles, is significant, but the
result is exactly the same.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas Kregeloh" wrote in message
...
Hi Tom,
yes, I use select. I have disabled the screen-update in order to increase
speed.
What's the problem about "select"? I did not yet think about turning
calculation off.
Regards
Thomas


"Tom Ogilvy" schrieb im Newsbeitrag
...
Do you use Select in your vba code? Does the screen flash all over the
place while your code is running?
If so, you might be able to dramatically increase the speed of your

macro
by
not using select or by setting ScreenUpdating = False and turning
calculation off.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Alternatives to VBA in Excel

Hi Bob,
is this also true when screen updating is switched off?
Thomas


"Bob Phillips" schrieb im Newsbeitrag
...
The problem with select is that it is slow, and if there is a lot of it
going on, it can make quite a performance difference. If on top of that

you
move between worksheets, that compounds the problem. For instance, this is
the sort of code that the macro recorder creates

Range("A1").Select
Selection.Value = "abc"

can be more efficiently written as

Range("A1").Value = "abc"

The amount of work removed here, and the CPU cycles, is significant, but

the
result is exactly the same.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Alternatives to VBA in Excel

Thomas -

Even with screen updating disabled, selecting cells and especially
activating worksheets can slow down the code.

Another big time waster is looping through a worksheet range and adding
cells to a VBA array one by one, then looping through the array to
repopulate the worksheet. Much better is to move the range into a VBA
variant in one step, and move the array back in another step:

dim vArray as Variant
vArray = Worksheets(1).Range("A1:D10").Value

now you can refer to vArray as if it were dimensioned (1 to 10, 1 to 4).
When you are done manipulating the array, or if by now it's in a
different array, you assign the range values to the array:

iRow = ubound(MyArray,1)+1-lbound(MyArray,1)
iCol = ubound(MyArray,2)+1-lbound(MyArray,2)
Worksheets(2).Range("A1").resize(iRow,jCol).value = MyArray

When I first learned this trick on an old 486 machine, it was amazing
how much more quickly it worked. On these newer GHz machines, it's less
of a difference, but still noticeable.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Thomas Kregeloh wrote:

Hi Bob,
is this also true when screen updating is switched off?
Thomas


"Bob Phillips" schrieb im Newsbeitrag
...

The problem with select is that it is slow, and if there is a lot of it
going on, it can make quite a performance difference. If on top of that


you

move between worksheets, that compounds the problem. For instance, this is
the sort of code that the macro recorder creates

Range("A1").Select
Selection.Value = "abc"

can be more efficiently written as

Range("A1").Value = "abc"

The amount of work removed here, and the CPU cycles, is significant, but


the

result is exactly the same.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)





  #7   Report Post  
Posted to microsoft.public.vc.mfc,microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Alternatives to VBA in Excel

Thomas,

Before you go down the C++ route, why don't you post the code. There are
many techniques to improve performance woithout writing C++ XLLs or DLLs.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas Kregeloh" wrote in message
...
Hi,
excuse my cross-posting, but I do not know which NG is the appropriate for
my problem.
I wrote an Excel-Macro in VBA which reads a text file, interprets this

file
and then does in Excel what has to be done: format cells, put values to

it,
storing files, inserting worksheets etc.
This works well, as designed, but is not very fast.
So I look for a way to increase speed.
I have Visual C++ 6 in Visual Studio. Can I rewrite my macro in Visual C++
so that it gets faster? If yes, where do I find "easy to understand"
descriptions how to do this? What do I need additionally?
TIA
Thomas Kregeloh




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Alternatives to VBA in Excel

Well, Bob,
I do not dare to put some hundreds loc into this message. It is a system
which can do quite a lot of formatting and manipulating the Excels sheets
and workmaps that itproduces, incl. defining its own subroutines,
administrating variables etc.
Thomas

"Bob Phillips" schrieb im Newsbeitrag
...
Before you go down the C++ route, why don't you post the code. There are
many techniques to improve performance woithout writing C++ XLLs or DLLs.



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
Alternatives for Excel when too few rows Jesper Excel Discussion (Misc queries) 6 April 2nd 08 11:03 PM
Alternatives for Excel for charting dated time-series? Matthew Pollock Charts and Charting in Excel 2 March 7th 05 01:20 PM
Alternatives to Excel Spider Excel Discussion (Misc queries) 2 March 1st 05 01:03 PM
Pocket Excel Alternatives? MB7 Excel Discussion (Misc queries) 0 February 16th 05 04:03 PM
OLDEDB alternatives for pulling data from Excel Glenn Thimmes Excel Programming 0 April 14th 04 03:37 PM


All times are GMT +1. The time now is 07:50 PM.

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

About Us

"It's about Microsoft Excel"