Solving Multiplication Of Two Matrices With Entries Decimal
Mar 16, 2014
Problem solving multiplication of two matrices with entries decimal in vba code:
Code:
Option Explicit
Public MatrixA(30, 30) As Long
Public MatrixB(30, 30) As Long
Public MatrixC(30, 30) As Long
Public RowA As Integer
Public ColA As Integer
Public RowB As Integer
Public ColB As Integer
I just started using VBA and WOW at the possibilities!! I have some data I am trying to calculate and decided upon researching VBA that this would be the easiest way to do what I need to. The code goes through no errors but D2 is .0001 and N2 is 12000 and the answer I get when I multiply the 2 through VBA is 0.000 however if I change the number in D2 to 2 then I get 24000. I tried the help menu and possibly this is because I didn't do something right with the decimal?
Many years ago I created a complicated spreadsheet that calculated employees's leave, sick, vacation etc. The timekeeper would indicate the amount(s) used for a particular day and it would automatically calcuate. The problem with this is that the time keepers do not use .25, .50, or .75 for the fractured time. Instead they used .15, .30 and .45. Previously, I used a convuluted if statement looking to the right of the leave to figure out what and how to calculate it and I'm trying to revamp it to make it more streamlined.
I have following for change event in text boxes to only allow numerics e.g.
Private Sub txtGBP10_Change() If (Not IsNumeric(txtGBP10.Value) And (txtGBP10.Value <> "")) Then txtGBP10.Value = Left(txtGBP10.Value, Len(txtGBP10.Value) - 1) End If End Sub Private Sub txtShare10_Change() If (Not IsNumeric(txtShare10.Value) And (txtShare10.Value <> "")) Then txtShare10.Value = Left(txtShare10.Value, Len(txtShare10.Value) - 1) End If End Sub
Can I add some code so that the user can only add numeric entries to 2 DP (txtGBP) or 3DP(txtShare)
I have a table that I add rows to via a macro. I am trying to add correlation matrices that find the last row of the table, and include a certain number of rows above that to create a rolling correlation. For example, if I want the 2 week correlation, I would like the last 10 rows of data, but if I add another row, this formula should move down to incorporate the new row and deselect the now 11th day preceding. I do this manually but it is very time consuming.
I have two ranges: A1:F1 and A5:A10, 6 elements in each range. When I multiply one by the other I have to enter a formular in some cell (let's say, A14 - we will put the result there): "=MMULT(A1:F1, A5:A10)" and then press Ctrl-Shift-Enter. Very simple.
Question is this: suppose I do not know in advance that I will have 6 elements in each vector, it might be more than 6 or less than six. I will introduce an integer "n", which is the number of elements. Now I have to write a Sub that will perform multiplication. I wrote smth that does not work and I was wondering if someone has ever done this already and can give me a guidance what I am doing wrong. I HAVE ONE CONSTRAINT: I HAVE TO TYPE IN THE FORMULA INTO THE SPREADSHEET VIA VBA (as this will be used further in Solver, which requires formulas to be present in cells).
Y Sub test() Dim n n = 2 Range("A14").Formula = "=MMULT(A1: & Chr(64+n-1)& 1, A5:A & 5+n-1)" End Sub
I thought it would be equivalent to MMULT(A1:B1, A5:A6).
I have a matrix with default probabilities. I have this matrix in my worksheet. The user will give the number of periods to be calculated with and it will result in a new matrix with default periods over time of choice.
Private Sub UserForm_Click() Dim numberof_text_Change As Single Dim initial_text_Change As Single
Range("U36:AC44").Select Selection.FormulaArray = "=matrixpower(R[-10]C:R[-2]C[8],numberof_text.value)" End Sub
matrixpower is a function that works perfectly well. It takes one matrix as an argument and the number of periods to use. It then simply computes the chosen number of powers of my matrix. I have a userform that has an inputbox called numberof_text which specifies the number of periods that the user wishes to use in calculating the chance of default. Hence I would like to use this variable as an argument in the formulaarray. This doesn't seem to work! I only get "#VALUE!" in every cell. If I replace "numberof_text.value" in the matrixpower function with a number it works fine. What to do?
What the function needs to do is take an argument which is the matrix I have on my spreadsheet. Take the number of times to take powers of the matrix and print it on a pre-specified place on the worksheet. If I cannot use variables with FormulaArrays, then is there another good way of choosing the matrix to use with "powermatrix"?
I don't actually own Excel as yet - but I'm wondering if someone could tell me whether Excel is capable of solving what I'm told are 'polynomial equations'. An example of the sort of equation I hope to solve is: d/(1.18 + d) + d/(1.86 + d) + d/(9 + d) + d/(8.8 + d) = 2 d=? {I happen to know d = 3.65(approx) in this example btw}
I am trying to analytically solve an equation to establish a physical value. Unfortunately, it's difficult to do the algebra, so it needs to be done this way.
I have an experimental value for this in "J2", so what I want to do is change F2 to that "I2" is equal to "J2"
Is it possible to get excel to match these values - I have about 200 different cells of this?
The formula is in cell "I2" =B2*((1-(C2/D2)*((F2/G2)^1.2))^-1.5125)
I had 4 initial temperature values and after some time i got new temperature values. Now for calculating 2nd iteration i need to use new calculated values and for third iteration values from 2nd iteration is to be used and so on.
How to calculate temperature values directly for 10th iteration without solving each iteration?
I have a vba macro that takes data from one workbook and pastes it into another workbook. In doing this I have declared a few variables of type single (I only need two decimal precision). However, when I copy the values from the cells on the source workbook and paste them into the target workbook, the numbers end up having 12 decimal places. Ultimately, this extra precision causes my totals to be off by .01 or more after a while. I have tried rounding the number as I pull it off the source workbook into the variable, but that didn't matter. How do I solve this problem? Code for pulling data from source workbook:...
Basically, I want to format a group of cells to display 1 decimal figure if the number is not a whole number. If the number is a whole number (or if the rounded first decimal place is 0) I want it to display no decimal.
I need to convert a column of numbers currently formatted with 2 decimal places e.g. 112.12 to 4 decimal places (without the decimal point). I need the end result to be 1121200. I've tried a few different suggestions given on the forum previously but can't seem to retain the 4 decimal places that I require.
I am trying to create a unique sample code by putting together the values of other cells that a user will input. It's all working well apart from the last part, where I am trying to include a decimal number. I want the decimal number to appear without the central "." and in a four digit format. e.g. 2.5 would appear as 0250, 14.25 would appear as 1425. This is the formlua I am using currently:
However, where the value of H4 is 2.5, I am getting a result of 0303 (I've put this part in bold). I have attached a small spreadsheet to aid understanding.
what i am trying to do is multiply the numbers in two seperate cells on the same row (e.g. C1*D1) and do this for the whole column where there is data (so it could go down to (C9*D9)
I was wondering how I would execute this in a macro, I am also looking to show the total value of all these added together but one step at a time
As I have illustrated in the example below, I want to multiply a value by 1.(something). The 1. is always constant, where the I8 cell is variable. I can't get this to work.
I have a worksheet with many lines of inputted numbers (values). I want to divide each number in the sheet by 4. However, I don't want to move any of the numbers because other sheet in the workbook refer to these cells. Does anyone know how i can do this easily?
I need a formula to multiply only the decimal number in a cell and not the integer. For example: the number in the cell is 57.3615. I want to multiply .3615 only.
I obviously know less about functions than I thought I did. I've got the attached spreadsheet set up except getting totals at the bottom. The production total L44, would be column A multiplied by the quantity entered in columns L and summed. Same for Total SF, square footage in column B times quantity in L and summed at the bottom. This would continue daily, needing sums under each column.
3. The program should ask the user what two numbers from 1-10 would he like to multiply.
4. The program should not multiply the two numbers but instead use the two numbers as reference for the element number and locate the corresponding element.
5. The corresponding element should have the value same as the product of the two numbers entered by the user.
Part 2:
1. Do the same as Part 1 but this time automate the creation of the multiplication table using the concept of array.
Here's what I've done so far for part 1
[Code]...
But when I enter the two numbers It just displays the value in cells(2,6)
I am writing a spreadsheet as a report for a customer and i want to show the following in the sheet.
A customer buys 12 of XProduct (retails £2) A customer buys 15 of YProduct (retails £3) A customer buys 20 of ZProduct (retails £5)
I want the sheet to have columns stating - Amount Bought - Product - Gross Amount.
And i want to be able to have the product column intelligent enough to know that if i type any of my products sold it will automatically attribute the correct cost (i.e. I type in Xproduct and it knows that value is £2) so that in the Gross Amount column it will all make sense, and save me having to manually put in the retail cost each time which will occasionally change. At present i have the same three columns and i multiply the Amount Bought with what i know is the cost and do the sum myself and then enter the result in excel -
Below, starting from b4 to l4 I have years from 2005 to 2015, row 5 for the same range contains data, row 6 (c to l) contains a growth rate.
I need to come up with a formula that can multiply (x * y * z *... [product-like formula]) the growth rates for all the years where the current year (row 4) is bigger than reference the reference year in a1 or smaller than reference year in a2. A3 is then used to multiply that total.
If I wanted to get a cell, say A1, to multiply a value, for example 7, by the results in another cell, say B1, but NOT multiply if that cell's value is a minus number, is there a way of getting Excel to do that?
Normally I'd just type =SUM(A1*B1)*7, but how can that be reconfigured to ignore minus numbers? e.g. if B1 contained -5, ?