Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Paste code running extremely slowly...

If that is all your doing, there is no reason to save the old value and use
the array the way you are doing it.

Sub OneTimeOnlyAdd()
Dim TempID As String
Dim NameArr As Variant

'pull in the long name for editing
For PullVals = 1 To 10000
NameArr= Sheet43.Range("O1:O10000").value
Next

'edit the name
FoundBlank = 0
For AddID = 1 To 10000
TempID = NameArr( AddID,1)
If Len(TempID) 0 Then
NameArr(AddID,1) = Right(TempID, Len(TempID) - InStr(TempID, "\"))
Else
FoundBlank = FoundBlank + 1
NameArr(AddID,1) = empty
End If
Next

Application.ScreenUpdating = False
v = Application.Calculation
Application.Calculation = xlManual
Sheet43.Range("W1:W10000")Value = NameArr
Application.Calculation = v
Application.ScreenUpdating = True
End Sub

--
Regards,
Tom Ogilvy


"KR" wrote in message
...
I had what I thought was a small and simple code snippet, but it was

running
very slowly. So, I broke it out into component actions to see what was
taking so long. The code is pasted below; the first part of the code runs

as
quickly as expected (considering the number of rows) but when I get to the
code to paste the data back into my worksheet, it seems to be taking about

1
second /per row/. Since I'm only pasting one value per row, and it is
already calculated, this seems very weird to me.

The sheet is not protected, and what is being pasted is never more than an

8
character string. Any ideas what might make this part of the code run so
painfully slowly?

Thanks,
Keith

-------------------------------------------------------
Sub OneTimeOnlyAdd()
Dim TempID As String
Dim NameArr(1 To 2, 1 To 10000)

'pull in the long name for editing
For PullVals = 1 To 10000
NameArr(1, PullVals) = Sheet43.Range("O" & Trim(Str(PullVals))).Value
Next

'edit the name
FoundBlank = 0
For AddID = 1 To 10000
If FoundBlank 20 Then Exit For
TempID = NameArr(1, AddID)
If Len(TempID) 0 Then
NameArr(2, AddID) = Right(TempID, Len(TempID) - InStr(TempID,

"\"))
Else
FoundBlank = FoundBlank + 1
End If
Next

'paste the name <----this is the part that slows to a crawl!! one second

per
loop! no sheet protection or anything, it just overwrites the current cell
value...
For PasteVals = 1 To 10000
Sheet43.Range("W" & Trim(Str(PasteVals))).Value = NameArr(2,

PasteVals)
Next

End Sub

--
The enclosed questions or comments are entirely mine and don't represent

the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.




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
Cut, copy & paste functions in Excel 2007 are extremely slow. Joe B.[_2_] Excel Worksheet Functions 3 June 2nd 10 02:29 AM
Paste Special is extremely slow Shaun Excel Discussion (Misc queries) 1 August 15th 08 12:13 PM
Copy / Paste extremely slow Isotope07 Excel Worksheet Functions 4 April 23rd 07 02:58 PM
Copy and paste link in worksheet is extremely slow. What to doÉ Franco Excel Discussion (Misc queries) 0 September 21st 05 04:41 PM
Macros in Excel 2000 running very slowly cottage6 Excel Programming 3 January 6th 05 09:43 PM


All times are GMT +1. The time now is 02: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"