data arrays

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Data Arrays

Data Arrays

resolvedResolved · High Priority · Version 2016

Martin has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Excel VBA Advanced course

Data Arrays

Hi Jens,
I hope you are well. I have a challenge for you.

I have created a data array containing all my raw data.
I have then added a line that finds and returns the column number with the heading Head Force Z.

Now that I have this I want to loop through this column in my data array from the lower to the upper bound selecting 5 cells at a time. I want to return the lowest value for each step.

Is there a way to specify a range within an array?

After selecting 5 cells I am going to be increasing it to 10,15...up to 80 cells at a time.


What I have written so far is below..


Sub exceedance()
Sheets("Raw Data").Range("a1").Select

cols = Sheets("Raw Data").Range("a1").CurrentRegion.Columns.Count

For j = 1 To cols
If Sheets("Raw Data").Cells(1, j) = "Head Force (Z-Axis)" Then
HeadForceZ_col = j
Exit For
End If

Next j

dataarr = Sheets("Raw Data").Range("a1").CurrentRegion

For i = (LBound(dataarr, 1) + 1) To UBound(dataarr, 1)

minval = Application.WorksheetFunction.Min(dataarr(i, HeadForceZ_col), dataarr(i + 5, HeadForceZ_col))

'this compares the 5th and 1st cell and returns the minimum of the 2 not the cells between

Next i


End Sub


Kind regards

Martin



RE: Data Arrays

Hi Martin,

Thank you for the forum question.

Yes it is a good challenge.

My first thought was to create another array with 5 rows and then move 5 rows at the time from the first array to test for min. I have a course tomorrow but I have time to test my idea Friday and I will come to you Friday.


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Data Arrays

I will also give this a try tomorrow see how I get on.
Just to clarify I am moving 1 cell at a time down the array analysing 5 rows each time.

RE: Data Arrays

Hi Martin,

If you send me an email, I will send you the solution.

jens.bonde@stl-training.co.uk


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Reset Excel toolbars to default settings

If you find any of your toolbars in Excel have changed (i.e. they are missing or have extra buttons) then you can reset them to their defaults.

1. Go to Tools - Customise.
2. Select the Toolbars tab.
3. Select (highlight) the name of the toolbar you wish to reset, then click the Reset button on the right.
4. Close the dialogue box.

View all Excel hints and tips


Server loaded in 0.12 secs.