Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Array question

I was doing copy the source row, then pastespecial paste:=values only. Like
I said, the laptop I use at work is pretty hurtin'. I did try the
screenupdate line, and it worked beautifully. It actually shaved another two
or three seconds off the time. One thing I am noticing, though, is that even
though this laptop, with a single core 1.6g processor, 2G of ram, and Excel
2003 is slow by today's standards, my personal laptop has a dual core 1.8g
processor, and 4G of ram with Excel 2007, and the same macro takes twice as
long to run on the newer machine. Could this be that Excel is not programmed
to benifit from multi-threading?

"Rick Rothstein" wrote:

Since you didn't post any code, it is hard to tell what you are doing, but I
suspect you are doing a Copy in one line and then a PasteSpecial in another
line. If you don't mind copying everything from the source range (that would
be formula, values, formats, etc.), then you can do this in a single line of
code. Say your source range is C3:H9 on Sheet1 and you wanted to copy this
to a destination whose top left cell is M12 on Sheet2, then you could do
like this without using any arrays...

Worksheets("Sheet1").Range("C3:H9").Copy Worksheets("Sheet2").Range("M12")

By the way, did you try my Application.ScreenUpdating suggestion with your
original code? That should have hidden the blinking dashed lines during your
codes execution.

--
Rick (MVP - Excel)


"Greg Snidow" wrote in message
...
Rick, thanks for the tips. I think I actually read the post you
referenced,
and so I am not selecting any ranges, but rather just pasting into them
without selecting them as your post suggests. However, every time I copy
a
range, the blinking dashed lines appear around the range, then jump to the
next range I'm copying, then it jumps down to the range to which I am
writing, even though I am not selecting. Is there a way to avoid
Range("somerange").copy? The arrays seem to do the trick. My screen is
almost perfectly still, while the values being passed from the array just
populate quietly.
"Rick Rothstein" wrote:

Oh, I meant to include the following in my other post...

You can stop the screen jumping problem by freezing the screen during
processing. Put this statement at the beginning of your code...

Application.ScreenUpdating = False

and then put this next statement at the end of your code...

Application.ScreenUpdating = True

Note that if your code crashes (errors out), then the second statement
above
will not have executed and your Excel screen will be frozen. If that
happens, you can "unfreeze" it by executing the second statement above
directly in the Immediate Window. If you have any error trapping enabled
and
if that code ends the execution of your code, then you should include
this
statement within that error trapping code so that it will "unfreeze" the
screen automatically for you.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
The screen "jumping all over the place" problem is probably due to your
continually changing what is selected. You rarely have to select a
range
(single or multiple cells) in order to operate on them. Here is how I
have
explained it in the past...

Perhaps this previous posting of mine (a response to another person
using
Select/Selection type constructions) will be of some help to you in
your
future programming...

Whenever you see code constructed like this...

Range("A1").Select
Selection.<whatever

you can almost always do this instead...

Range("A1").<whatever

In your particular case, you have this...

Range("C2:C8193").Select 'select cells to export
For Each r In Selection.Rows

which, using the above concept, can be reduced to this...

For Each r In Range("C2:C8193").Rows

Notice, all I have done is replace Selection with the range you
Select(ed)
in the previous statement and eliminate the process of doing any
Select(ion)s. Stated another way, the Selection produced from
Range(...).Select is a range and, of course, Range(...) is a range...
and,
in fact, they are the same range, so it doesn't matter which one you
use.
The added benefit of not selecting ranges first is your active cell
does
not change.

--
Rick (MVP - Excel)


"Greg Snidow" wrote in message
...
OssieMac, thank you for the elementary explanation. The reason I'm
interested in arrays is I have many workbooks that copy and paste
ranges
inside of loops, so the ranges change with each i, so the screen is
jumping
all over the place, and it just looks bad. So, I am gathering that
once
I
Dim the array, say MyArray(), and I put it in a loop where for each i,
MyArray = SomeVariableRange, the values for the new range will
overwrite
the
existing values in the array from the previous i? I tried it out on a
loop
that copies a solver solution range for 70 runs, and populates a
report
section. The data seemed to be no different than if I had copied and
pasted
the ranges. Am I missing something, or is this how they are supposed
to
work? Thanks again.

Greg

"OssieMac" wrote:


Also Google (or other favourite search engine) "excel vba array
tutorial"
and you should find some more info.


--
Regards,

OssieMac



.


.

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
array question Mona Excel Discussion (Misc queries) 2 March 23rd 10 08:41 PM
I think I have an array question... hshayh0rn Excel Programming 5 April 5th 06 09:09 PM
Array question Jim Simpson Excel Programming 3 September 22nd 04 04:40 AM
Array question Stuart[_5_] Excel Programming 1 August 6th 03 04:13 AM
Is this an array question? Stuart[_5_] Excel Programming 0 August 5th 03 08:53 PM


All times are GMT +1. The time now is 03:22 AM.

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"