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: 12
Default subscript out of range - how to determine

Hello everyone,

Below is my function I am trying to write. The problem I am running
into is that I cannot figure out what line of code will allow me to
exit the loop once y0(1,A) = <subscript out of range, ie there are no
more columns in the range. Can anyone point out how to trap/exit when
this error occures so that I can exit and the A value is the number of
columns in the range?

Can anyone help me out here?

Cheers,

Jack


Function SumAbs(y0 As Range)
'this function will return the sum absolute value from all the cells
in the range provided

Dim A, B, Counter,Counter2 As Integer

A = 1
Do While y0(1, A) < ""
A = A + 1
Loop
A = A - 1

B=Application.Count(y0)/A ' this part determines how many rows are
in the y0 range by dividing the total count by the amount of columns
(A)

SumAbs=0

For Counter2= 1 to A
For Counter = 1 To B

SumAbs = SumAbs + Abs(y0(Counter, Counter2))

Next Counter
Next Counter2

End Function

 
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
Subscript out of range Greg Glynn Excel Programming 3 October 11th 06 10:43 PM
Subscript Out of Range ExcelMonkey[_190_] Excel Programming 6 February 20th 05 02:46 AM
Subscript Out of Range Al Excel Programming 5 September 22nd 04 07:07 PM
subscript out of range Todd Huttenstine[_3_] Excel Programming 1 June 11th 04 04:08 AM
Subscript out of range Ed Excel Programming 1 February 5th 04 07:17 PM


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

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

About Us

"It's about Microsoft Excel"