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: 2
Default Given a range of cells, some of which contain errors (e.g. #DIV/0), replace each cell having an error with the value of a non-error precedent cell

What I a trying to do:
Given a range of cells, some of which contain errors (e.g. #DIV/0),
replace each cell having an error with the value of the last cell in
the range that is
a) not an error &
b) is before the current cell

Example:
Input: 2.05 #DIV/0 #DIV/0 2.55 #DIV/0
Return: 2.05 2.05 2.05 2.55 2.55

Attempt at Code:
Function SuperASP(ASP As Range) As Range
Dim Size As Integer
Dim Size2 As Integer
Size = WorksheetFunction.CountA(ASP) - 1
Size2 = Size
For i = Size To 0 Step -1
If Not WorksheetFunction.IsError(ASP(i)) Then
For j = Size2 To i Step -1
SuperASP.Cells(i).Value = ASP.Cells(i).Value
Next j
Size2 = i
End If
Next i
End Function

Current Input: ={SuperASP(B5:M5)}
Current Output: #Value is returned for each cell in the range

As is obvious from the code, I am misunderstanding quite a bit. Any
corrections to the code, or suggestions on a better to do this are
appreciated.

Thank you,
Barclay

 
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
#Value! error when evaluating data in a cell range Simon Woods Excel Worksheet Functions 7 January 13th 09 10:38 PM
Double clicking formula cell doesn't highlight precedent cells jwaber Setting up and Configuration of Excel 0 September 7th 07 08:44 PM
How to have an error popup once range cell amount is greater than Daniel Bunt Excel Discussion (Misc queries) 2 January 27th 07 02:58 PM
Help with this error Unknown reason for error with Range().Select Brad Sumner Excel Programming 1 September 13th 05 04:24 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


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