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

Greeting,

I'm trying to use an array to complete a task. The following code is what I
have thus far, but get an error on the 2nd line (OSRCount is the array). I
need to make this loop work for each item in the arraym but don't really know
how to do that.

-----Function--------------------------
For Each OSRCount In OSRList
Do While RowEnd < RowEnd + (2 * OSRCount / 3)
Range(Cells(RowStart, ColumnStart), Cells(RowEnd, ColumnStart +
2)).Select
Selection.Cut
Range(Cells(RowStart - OSRCount / 3, ColumnStart + 5),
Cells(RowStart - OSRCount / 3, ColumnStart + 5)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
RowStart = RowStart + Round(2 * (OSRCount / 3))
RowEnd = RowEnd + Round(2 * (OSRCount / 3))
ColumnStart = ColumnStart + 4
Exit For
Loop
Next
------- Definition of Array --------------------------------
OSRList = Array("BS", "CK", "HS", "IT", "JD", "JW", "KC", "KF", "MG",
"MM", "SM", "TS", "VD")
For Each OSRCount In OSRList
OSRCount = Application.CountIf(Sheets("ALLACCT").Range("B:B") ,
OSRList)
Exit For
Next
--------------------------------

Any help would be really appreciated!,
-m
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default For Each Array Question

You can loop through an array like this

For i = LBound(OSRCount) To UBound(OSRCount)
msgbox OSRCount(i)
Next i

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"mvyvoda" wrote in message
...
Greeting,

I'm trying to use an array to complete a task. The following code is what

I
have thus far, but get an error on the 2nd line (OSRCount is the array). I
need to make this loop work for each item in the arraym but don't really

know
how to do that.

-----Function--------------------------
For Each OSRCount In OSRList
Do While RowEnd < RowEnd + (2 * OSRCount / 3)
Range(Cells(RowStart, ColumnStart), Cells(RowEnd, ColumnStart

+
2)).Select
Selection.Cut
Range(Cells(RowStart - OSRCount / 3, ColumnStart + 5),
Cells(RowStart - OSRCount / 3, ColumnStart + 5)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
RowStart = RowStart + Round(2 * (OSRCount / 3))
RowEnd = RowEnd + Round(2 * (OSRCount / 3))
ColumnStart = ColumnStart + 4
Exit For
Loop
Next
------- Definition of Array --------------------------------
OSRList = Array("BS", "CK", "HS", "IT", "JD", "JW", "KC", "KF", "MG",
"MM", "SM", "TS", "VD")
For Each OSRCount In OSRList
OSRCount = Application.CountIf(Sheets("ALLACCT").Range("B:B") ,
OSRList)
Exit For
Next
--------------------------------

Any help would be really appreciated!,
-m



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 keeblerjp Excel Discussion (Misc queries) 4 June 20th 06 04:21 PM
array question Gary Keramidas[_4_] Excel Programming 4 October 4th 05 03:40 AM
Array Question I think DanVDM Excel Programming 2 July 11th 05 07:33 PM
Array Question Renee Excel Worksheet Functions 0 June 29th 05 07:10 PM
Array Question andym Excel Programming 3 September 2nd 04 02:34 PM


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