ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Arrays problem (https://www.excelbanter.com/excel-programming/339614-arrays-problem.html)

Ali Baba

Arrays problem
 
I want to write a function in VBA which multiplies two numbers together as
follows

=Multiply(A,B,5)

A is the first value
B is the array, eg. A1:A10
5 is the 5th value of the array.

Would anybody be able to help me with this ?

Thanks

Chip Pearson

Arrays problem
 
Try something like

Function Mult(Num1, Rng As Range, N As Long) As Double
Mult = Num1 * Rng.Cells(N)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ali Baba" wrote in message
...
I want to write a function in VBA which multiplies two numbers
together as
follows

=Multiply(A,B,5)

A is the first value
B is the array, eg. A1:A10
5 is the 5th value of the array.

Would anybody be able to help me with this ?

Thanks




Tom Ogilvy

Arrays problem
 
Public Function Multiply(num as double, b as Range, idx as Long)
Multiply = num * b(idx).Value
End Function

--
Regards,
Tom Ogilvy

"Ali Baba" wrote in message
...
I want to write a function in VBA which multiplies two numbers together as
follows

=Multiply(A,B,5)

A is the first value
B is the array, eg. A1:A10
5 is the 5th value of the array.

Would anybody be able to help me with this ?

Thanks




Tushar Mehta

Arrays problem
 
What have you tried and where are you stuck?

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I want to write a function in VBA which multiplies two numbers together as
follows

=Multiply(A,B,5)

A is the first value
B is the array, eg. A1:A10
5 is the 5th value of the array.

Would anybody be able to help me with this ?

Thanks



All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com