473,408 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Product in vba/excel

Can someone give some hints???
Id like to know if someone have a code for visual basic/ excel to calculate the the product of a sequence of numbers in VBA, i'm using windowns 7/vista.The definition of the product of n numbers is https://es.wikipedia.org/wiki/Productorio

What i already tried:
Function mo( j, n)


Dim x As Double, j As Double

x = 10 -1/n

For j = 1 To n
s = Application.WorksheetFunction.Product(x)

Next
mo = t
End Function

I used Application.WorksheetFunction.Product(x) from excel and nothing happened. It didn't work.

x = 10 -1/n is the number generating function for j from 0 to n
i want the Product of all the numbers that are generated from that equation.
for example, from 1 to 10 the resulting numbers would be:9
9,5 9,666666667 9,75 9,8 9,833333333 9,857142857 9,875 9,888888889 9,9
P= 9,5* 9,666666667* 9,75* 9,8 * 9,833333333 *9,857142857 9,875* 9,888888889* 9,9 = 7400228969

In general, i want Product function in VBA of all the numbers that are generated from that equation (x = 10 -1/n) in order to put in a simpler way inside another more large complicated (mind-blowing) equation .


Expand|Select|Wrap|Line Numbers
  1. Function mo( j,  n)
  2.  
  3.  
  4. Dim  x As Double, j As Double
  5.  
  6. x = 10 -1/n
  7.  
  8. For j = 1 To n
  9.  s = Application.WorksheetFunction.Product(x)
  10.  
  11. Next
  12. mo = t
  13. End Function
I'm looking forward to receiving good news.

Thanks in advance
May 22 '17 #1
4 1563
PhilOfWalton
1,430 Expert 1GB
I'm afraid I have little knowledge of Excel, but I suspect you want something more like

Expand|Select|Wrap|Line Numbers
  1.  Function mo(J, n) As Double
  2.  
  3.     Dim i As Integer
  4.     Dim x As Double
  5.  
  6.     mo = J
  7.     For i = 1 To n
  8.         x = J - (1 / i)
  9.         mo = mo * x
  10.     Next i
  11.  
  12.     mo = mo / J
  13.  
  14. End Function
  15.  
If I Type Debug.Print (mo(10,10) I get 7400228969.41453

I suspect it may need rounding off

Phil
May 22 '17 #2
OK. THANK YOU SO MUCK. MO WORKS NOW.
But i need insert MO in other vba formula by using the same previous generating function for MO (x = 10 -1/n):
Function summot(j, n) As Double
For j = 1 To n
sum = sum +Application.Combin(n,j)*Application.WorksheetFunc tion.mo(n,j)
Next
summot= sum
End Function

For example, i'd like to calculate for j=9 n=9
Can u tell me please how to calculate the sum above that?
many thks in advance

Expand|Select|Wrap|Line Numbers
  1. Function summot(j, n) As Double
  2. For j = 1 To n
  3. sum = sum +Application.Combin(n,j)*Application.WorksheetFunction.mo(n,j)
  4. Next
  5. summot= sum
  6. End Function
  7.  
May 22 '17 #3
PhilOfWalton
1,430 Expert 1GB
Sorry, I can't help further. As I said, Excel is not my forte.

Phil
May 22 '17 #4
ok many thks bro.

Can Someone , please, provide further help? many thks in advance
May 23 '17 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: dtsearch | last post by:
Press Contact: Belinda Banks S&S Public Relations (212) 946-2823 Belinda@sspr.com Announcing New dtSearch® Product Line Version Release Enhances Indexing, Searching and Display of MS Word,...
17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
9
by: Nathan | last post by:
A couple of months ago, I went looking for a .NET grid component with what I thought was pretty simple criteria - I wanted an interface that provided my users with Excel-like data entry capability....
2
by: Steve Chatham | last post by:
I use the following code: Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged Dim sFile As String =...
5
by: Tim Frawley | last post by:
I created a .NET Com Class object for use in ASP reports to export database results directly to Excel. I have it all working just find but I cannot get the Excel process to go away after the job...
2
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages...
1
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is...
8
by: Bruce_Stough | last post by:
I am currently using Control.DoDragDrop to drop a text string into Excel. I use the following code DataObject dd = new DataObject();...
1
by: codexxx | last post by:
Hi All, We have setup an Amazon webstore and we anticipate uploading 10,000+ products, and therefore to avoid unnecessary manual labor we wish to automate as much of the process of adding and...
4
by: atanu | last post by:
Hi! I am Atanu. I am working in a company dealing with manufacturing of mechanical spear parts. When we release a product for manufacturing we make drawing and given the same to the factory. To make...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.