Looping through a Range of Data

Needtoknow

Board Regular
Joined
Apr 21, 2006
Messages
73
How can I loop through a range of data (A5:H20) such that the following code is called over and over going down cells E and G until it reaches the bottom with no data

Call CODE_ABC(Range("E11"), Range("G11"))

Part 2:
How can do this based on specific text in column A (for example when it only sees the name "Task A", Task "B", etc.).
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
this shoud do it. Note I have used a varaint aarray by loading the data from column A into array "Inarr" the reason for doing this is that VBA is very slow at accessing the worksheet cell by cell. loading the whle column takes about the same time. So doing it this way is faster. For 20 rows it doesn't make much difference but over 20000 it would. So I always load into variant if I can.
Code:
Sub test()
inarr = Range("A1:A20")
For i = 5 To 20
  If inarr(i, 1) = "task A" Then
    Call CODE_ABC(Range("E" & i), Range("G" & i))
  End If
Next i


End Sub
 
Upvote 0
Apologies on the cross posting. I value these types of sites very much. I read the link.

Please take this as my sincere apologies.

BTW, the code works great. Thank you
 
Upvote 0
Just to clarify the forum's policy on Cross-Posting, while we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top