Hey everyone, first time poster, so go easy on me. I need to take Range A, containing drop-down values, assign them a number according to their value, then multiply Range A by another range (Range B), then subtract the product from the Sum of Range B. NOTE: "Range A values" shouldn't actually appear on the spreadsheet, they are just included for reference.
<table style="width: 412px; height: 156px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 48pt;" width="64"> <col style="width: 77pt;" width="103"> <col style="width: 48pt;" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 48pt;" width="64" height="20">Range A</td> <td style="width: 77pt;" width="103">Range A Values</td> <td style="width: 48pt;" width="64">Range B</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">PTO</td> <td align="right">1</td> <td align="right">0.5</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">HPTO</td> <td align="right">0.05</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">TRN</td> <td align="right">1</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">HTRN</td> <td align="right">0.05</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl68" style="height: 15pt;" height="20">HLDY</td> <td align="right">1</td> <td align="right">0.5</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl68" style="height: 15pt;" height="20">
</td> <td align="right">0</td> <td align="right">1
</td> </tr> </tbody></table>
Here's what I have for my VBA code so far, but I'm pretty sure I did some very illegal methods (like multiplying two ranges).
Logic goes as follows:
Input Range A and Range B
Sum Range B
Convert Range A to correct Values
Multiply Range A Values by Range B (row by row basis)
Sum the product
Subtract the product from the Sum of Range B
-----------------------------------------------------------------
---------------------------------------------------
Unfortunately, I've looked into pretty much every workaround I can think of, and this is pretty much the only way I can do this (meaning I have to follow the logic listed above). It also has to be a self-contained function for ease of use, because someone besides myself will be updating this file later. I plan to write a how-to file, but want to keep it as clean as possible on the surface.
Thank you for your help!
Let me know if I can give more details that would help.
<table style="width: 412px; height: 156px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 48pt;" width="64"> <col style="width: 77pt;" width="103"> <col style="width: 48pt;" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 48pt;" width="64" height="20">Range A</td> <td style="width: 77pt;" width="103">Range A Values</td> <td style="width: 48pt;" width="64">Range B</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">PTO</td> <td align="right">1</td> <td align="right">0.5</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">HPTO</td> <td align="right">0.05</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">TRN</td> <td align="right">1</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl67" style="height: 15pt;" height="20">HTRN</td> <td align="right">0.05</td> <td align="right">1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl68" style="height: 15pt;" height="20">HLDY</td> <td align="right">1</td> <td align="right">0.5</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl68" style="height: 15pt;" height="20">
</td> <td align="right">0</td> <td align="right">1
</td> </tr> </tbody></table>
Here's what I have for my VBA code so far, but I'm pretty sure I did some very illegal methods (like multiplying two ranges).
Logic goes as follows:
Input Range A and Range B
Sum Range B
Convert Range A to correct Values
Multiply Range A Values by Range B (row by row basis)
Sum the product
Subtract the product from the Sum of Range B
-----------------------------------------------------------------
Code:
Function FTE(TypeOff As Range, Multiplier As Range) As Double
Dim TypeItm As Range, MultItem As Range
Dim FTEMax As Double
FTEMax = WorksheetFunction.Sum(Multiplier)
For Each TypeItm In TypeOff
If TypeItm = "PTO" Or TypeItm = "TRN" Or TypeItm = "HLDY" Then
TypeItm = 1
ElseIf TypeItm = "HPTO" Or TypeItm = "HTRN" Then
TypeItm = 0.05
Else
TypeItm = 0
End If
Next TypeItm
Dim FTEDaysOff As Range
FTEDaysOff = TypeOff * Multiplier
Dim GrossDaysOff As Long
GrossDaysOff = WorksheetFunction.Sum(FTEDaysOff)
FTE = FTEMax - GrossDaysOff
End Function
Unfortunately, I've looked into pretty much every workaround I can think of, and this is pretty much the only way I can do this (meaning I have to follow the logic listed above). It also has to be a self-contained function for ease of use, because someone besides myself will be updating this file later. I plan to write a how-to file, but want to keep it as clean as possible on the surface.
Thank you for your help!
Let me know if I can give more details that would help.