multiply each row in array by %

john316swan

Board Regular
Joined
Oct 13, 2016
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
I have a sheet with table of data and I need to apply a different percentage to each row of data going into the array. For example

ACADAEAF...all the way to CR
Proratescholarship1scholarship2scholarship3scholarship4
.675000100020003000
.454000300055002500
13500100035001000
.981000200030004000

Now i need to multiply each scholarship in the row (from column AD to column CR) by the corresponding % in column ac.

I can loop through but that takes a bit of time and i was trying to speed it up so i thought that an array would be best. Thanks for your help!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Do you care about overwriting your original scholarship amounts? If not, you can select all of the values in column AC, Ctrl-C to copy that selection array to the clipboard, and then select the entire group of scholarship values (i.e., all rows from column AD to column CR corresponding to the Prorate column), and perform a Paste > Paste Special and select the option to "Multiply" and confirm with OK.

That will overwrite your current scholarship values with the prorated amounts.
 
Upvote 0
Yes, that would work but i should have mentioned I am trying to write it in VBA.
 
Upvote 0
Ah, I figured it out from WiseOwl Tutorial:

VBA Code:
Sub FormulaLoad()
Dim lr As Long
Dim MaxSch() As Variant
Dim dim1 As Long, dim2 As Long

Sheets(1).Activate
lr = Range("A1").End(xlDown).Row

'After scholarships have been prorated based on units, we're now going to prorate based on max sem eligibility
'Rows in Array, because these arrays begin at 0, we have to subtract 1 from each dimension
dim1 = lr - 1
'Columns in Array
dim2 = Range("AD2", Range("AD2").End(xlToRight)).Cells.Count - 1

'We declared it as a variant because we want a dynamic multi dimensional array so now that we now the rows and columns we can re-dimension the array
ReDim MaxSch(0 To dim1, 0 To dim2)

'Now we can write the values to the array
For dim1 = LBound(MaxSch, 1) To UBound(MaxSch, 1)
    For dim2 = LBound(MaxSch, 2) To UBound(MaxSch, 2)
        'here is where we input data from each cells
        MaxSch(dim1, dim2) = Application.WorksheetFunction.Round(Range("AD2").Offset(dim1, dim2).Value * Range("AB" & dim1 + 2), 0)
    Next dim2
Next dim1
'Delete it from memory
Erase MaxSch

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,235
Messages
6,123,786
Members
449,125
Latest member
shreyash11

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