VB excel ROWS and COLUMNS

In the function below i am trying to loop through an array of cells (Rows and Columns). I select the desired columns and i loop through the cells in that row in the columns i have chosen, then i move on to the next row and i do the same thing again.

for example
Col A  Col D  Col G
  2        4        5
  3                  1
            9

select/input columns A:D:G
select/input rows      1:2:3

what am doing is, the columns are stored in an array and the rows are stored in an array.
i want to have a nested for loop that loops thorugh the rows one by one. in the first row, the inner for loop goes thorugh each cell on that row to check if there is a value in it. the second row it does the same with the same columns selected.

CAN ANYONE help

how can this be done in VB
Function Coo(dat1() As Variant, dat2() As Variant) As Variant 'data2 As Variant, data3 As Variant) As Variant
'Dim cell As Range
Dim intI
Dim d
'For intI = 0 To UBound(dat1)
'For i = 1 To Range.Cells.Count
'For Each d In dat2
For Each intI In dat1
If intI Then
Coo = intI
Exit For
End If
Next intI
'Next d
End Function
sadupopsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimbobmcgeeCommented:
Do you need to go by row, then column, or do you just need to loop through all cells that you have selected?  Also, are you writing a VBA macro.  If so, try:

    Dim oCell As Excel.Range
    For Each oCell In Selection
        DoSomethingTo oCell
    Next oCell

HTH

J.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sadupopsAuthor Commented:
i need to go by row then column.
if i select cells
i want to go thorugh the cells row after row
then the second row
then the third

comparing all the cells in each row and getting some output to print into a selected column

sadupopsAuthor Commented:
PLS I NEED A SOLUTIONAS SOON AS POSSIBLE
leonstrykerCommented:
Do you still need help with this?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.