Using an array to manipulate and standardize data

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
Hi, I am working with tables in Excel and I am trying to automatically load the multicolumn table into an array,

I then want to calculate the AVERAGE for each table list column, the STDEV.P for each table list column and finally STANDARDIZE the data using the AVERAGE and STDEV.P I calculated earlier.

I think I understand how to load the table into an array but now how to actually loop through the data and manipulate it?

How can I loop through all list columns and calculate the AVERAGE for that list column, calculate the STDEV.P for that list column and finally calculate the STANARDIZE score?

Code:
Sub ArrayToStandardize()


Dim TableToArray As ListObject
Dim NewArray As Variant
Dim x As Long
Dim R As Long


ReDim NewArray(1 To 3, 1 To 100)


Set TableToArray = Sheets("Test1").ListObjects("Table1") 'Set path for Table variable
NewArray = TableToArray.DataBodyRange 'Create Array List from Table
For x = LBound(NewArray) To UBound(NewArray)
    
    NewArray(x, 1) = WorksheetFunction.Average(x, 1)
           
    'NewArray(x, 2) = WorksheetFunction.Average(x, 2)
    
    Debug.Print NewArray(x, 2)
    'Debug.Print NewArray(x, 2)
    'Debug.Print NewArray(x, 3) 
Next x
        
R = Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("Test1").Cells(2, 5).Resize(UBound(NewArray, 1), UBound(NewArray, 2)) = NewArray
  
End Sub
 
Last edited:
Hi,

I am still trying to automate the process of standardizing my data, I have it working manually but I want to learn how to automate a complex task like this with several calculations.

I want to calculate the average of each column, calculate the standard deviation of each column and then standardize each cell in every column with the average and the standard deviation.

How can I achieve this with or without arrays?

All help is very much appreciated!
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can anyone help me with this? How can I iterate through columns and taking the average of that column and saving the average into a variable and then writing the variable to the worksheet?
 
Upvote 0

Forum statistics

Threads
1,215,313
Messages
6,124,200
Members
449,147
Latest member
sweetkt327

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