I have the following assignment to do, problem is I'm new to arrays and functions in VBA and nothing is working for me, i get errors no matter what i try, (for example i don't know how to feed the array to the function, and it won't let me write a range to an array)
[COLOR="RoyalBlue"]5. A) Write a function that takes a 2D array of doubles, a single cell range, an optional cap and an optional floor.
B)Write the array on to the sheet with the single cell range parameter being the location of the top left of the array on the sheet. When writing the array to the sheet, for each value in the array where it is below the floor put the floor on the sheet, where the value is above the cap put the cap value on the sheet, otherwise display the original value. The input array should not be modified.
All code should be what you consider production quality.
here's my ideas for code, it's so bad i'm embarrassed, please help.
Dim topleft As Range array1 = Range("B8:C18").Value 'array1(1, 1) = 2 'array1(2, 1) = 3 'array1(1, 2) = 6 'array1(1, 3) = 9 'array1(2, 2) = 4 'array1(2, 3) = 5 topleft = Range("E8") 'writeArray(topleft, range("C4"), range("C5"),array1) End Sub Function writeArray(ByVal r As Range, floor As Single, cap As Single, _ ByRef InputArr As Variant) End Function