UPDATE: I've figured out a way to automate this code so that the only input that I need is the desired column for output. How do I get Excel VBA to accept that?
I have data that has values recorded at varied time points (20-360 minutes) and a drug dose recorded every 8-12 hours. I want to distribute that drug dose over all of the time entries since the last dose. My program's issues:
1. It won't accept DrugDose or Bounded as numerical inputs (Type=1)
2. It won't accept TimeRange of DrugRange as Arrays (Type 64)
3. I want to set bounded as the number of entries in Drug Range as:
Bounded = UBound(DrugRange) but I get an error that it expects an array value, regardless of whether DrugRange is type 8 or 64.
CODE
Sub Distribute()
Dim TimeRange As Range
Dim DrugRange As Range
Dim Bound As Integer, DrugDose As Variant
'Show input box to get range of cells for time
Set TimeRange = Application.InputBox(Prompt:="TimeRange", Title:="Distribute", Type:=8)
'Show input box to specify range of cells for output
Set DrugRange = Application.InputBox(Prompt:="DrugRange", Title:="Distribute", Type:=8)
'Show input box to set drug dose
Set DrugDose = Application.InputBox(Prompt:="DrugDose", Title:="Distribute", Type:=8)
'Show input box to get number of time points for distribution
Set Bounded = Application.InputBox(Prompt:="Bounded", Title:="Distribute", Type:=8)
'I want to determine as the size of the array DrugRange, but it states that it wants an array
'Even if I change the type to 64...
'Bound = UBound(TimeRange)
For k = 1 To Bounded
'Assign a value to each row of the array, allowing for a variable time range
DrugRange(k) = DrugDose * (TimeRange(k + 1) - TimeRange(k))/ (TimeRange(Bounded) - TimeRange(0))
Next
End Sub
This post has been edited by Soparklion: 27 Jun, 2009 - 07:47 PM