How to offset a for loop?

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
    Data = Sheets("Data").Range("Values2020").Value
   
    For i = 1 To UBound(Data)
   
         area = Data(i, 1)
         aval = Data(i, 2)
               
        myFunc area, aval
                
     Next i

First row is headers.

Column A contains names, column B to F contains values, named Values2020 to Values2025.

I am trying to offset Data somehow so that I can loop from column B to column F or column X...

I have tried with an outer loop:

VBA Code:
Dim j As Integer

For j = 1 to 5
    Data = Sheets("Data").Range("Values202" & j).Value
Next j

Any suggestions?
 
The idea of the function is that you pass it an array and it returns another array with the maxes per row of the passed array.
VBA Code:
MyMaxes = GetMaxPerRow(Data) ' get max values per row from Data
MyMaxes2 = GetMaxPerRow(Data2) ' get max values per row from Data2
What you then do with the returned arrays is up to you.
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Norie,

thank you for your reply!

Now your code is working in my spreadsheet, I'll try to modify it a little bit.
 
Upvote 0

Forum statistics

Threads
1,215,218
Messages
6,123,676
Members
449,116
Latest member
HypnoFant

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