Multiply range values with Lookup-value?
Sub MultiplyValues()
Dim rng1 as Range, rng2 as Range
Dim rng3 as Range, v as Variant
set rng1 = Range("A5",Range("A5").End(xldown))
set rng2 = Range("B1:D2")
for each cell in rng1
v = application.Hlookup(cell,rng2,2,0)
if not iserror(v) then
if isnumeric(v) then
set rng3 = cell.offset(0,1).Resize(1,5)
for each cell1 in rng3
cell1.value = cell1.Value * v
Next cell1
End if
End if
Next cell
End Sub
Test this on a copy of your data.
I assume the notation b6-value means the value of B6 and not B6 minus some
value.
--
Regards,
Tom Ogilvy
"Jen" wrote:
Hello again,
I am very very novice but Dave Peterson has been showing me how
usefull VBA can be!
Therefore I have another question which I haven't been able Google.
The case:
How can I "run" through a column from A5 eg till the the last value in
that column.
and multiply B5 till the end-row, C5 till the end-row,....till F
with an HLOOKUP-value performed on the A5-cell.
So:
for A5, B5 becomes: the initial B5-value * Hlookup(A5,$B$1:$D$2),2,0),
C5becomes: C5-value * Hlookup(A5,$B$1:$D$2),2,0),...till F5
for A6,B6 becomes: the initial B6-value * Hlookup(A6,$B$1:$D$2),2,0),
C6becomes: C6-value * Hlookup(A6,$B$1:$D$2),2,0).... till F6
....
etc till the end of column A.
The B till F C columns do not need the formulas, only the multiplied
value.
I am sorry for the "messy" explanation, I hope you can help me,
Jen
|