LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Can someone help me with this slow code

Hi,
I have a VB application, which starts and controls Excel. The program reads
the data from over 20 ASCII files and extracts that data and stitches it
together into one workbook by copy and paste actions.

Here is my problem, I do a lot of other things with my data, that goes very
quickly... I mostly set ranges to do this and either move or modify data
as ranges, or worksheet formulas. This code I past below is one section
where I don't know how to work with it as a range.

My problem code iterates a column to and find any occurrence of the value
"0".. If it finds a Zero it's a bad reading recorded by this instrument (a
spectrometer).. then I need to replace it with the previous row's value
because an electrical dropout is not a real reading, and a ZERO give me
divide by Zero errors for my other formulas added to the main spreadsheet...

does anyone know of a faster way to do this code below. If I write this
code inside an Excel file as a local macro, it runs extremely swift, but
when I use Excel as a remote it takes maybe 20 to 50 seconds this relatively
small iteration.

can someone please help me on this?
================================================== ===================================
Dim Ws As Worksheet, x As Long, y As Long
Set Ws = ActiveSheet: y = 2
With Ws
Application.DisplayAlerts = False
For x = 1 To 2000
If (Cells((500 + x), y).Value = "0") Then
Cells((500 + x), y).Value = Cells((500 + (x - 1)), y).Value
End If
Next
End With
Application.DisplayAlerts = True
================================================== ===================================


 
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
Slow Code Shawn Excel Programming 7 August 23rd 05 08:44 PM
FileSearch, my code is way too slow Jordan Excel Programming 13 May 24th 05 11:32 PM
SLOW Code... Ernst Guckel[_4_] Excel Programming 2 March 20th 05 10:58 AM
Slow Code Frank Kabel Excel Programming 1 July 23rd 04 09:28 AM
Is this slow code? Tom Excel Programming 4 March 3rd 04 11:18 PM


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