# Matrix of VBA

#### francesc

##### New Member
hi there
i am new to this forum and have a urgent question about the matrix application in VBA and want to ask you for help. the problem is about the deflection of a beam
the formula is
Q/EI = y(i-2)-4y(i-1)+6y(i)-4y(i+1)+y(i+2)
I want the output matrix is like this
1 -4 6 -4 1 0 0 0
0 1 -4 6 -4 1 0 0
0 0 1 -4 6 -4 1 0
.....
.....

is it possible?

### Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
it's not clear for me

it's not clear for me

in the VBA program, i know how to allow the user to enter the value in each cell of a matrix
but now i want to transform a "equation into a matrix", say 3x+5y-6z
and the matrix is a 4 by 6 matrix
i expect the output is
3 5 6 0 0 0
0 3 5 6 0 0
0 0 3 5 6 0
0 0 0 3 5 6
is it possible?

thank you very much

It would be easier to assign the values 3 5 -6 to 3 cells A1, A2, A3 then get the matrix

Last edited:
put known terms in the first row, then try this code,
Code:
``````Sub a()
kterms = 3
nrow = 4
ncol = 6
drow = 3 ' destination row
Set Rng = Range(Cells(1, 1), Cells(1, kterms))
Range(Cells(drow, 1), Cells(drow + nrow - 1, ncol)) = 0
For j = 0 To nrow - 1
Rng.Copy Cells(j + drow, j + 1)
Next
End Sub``````

Replies
10
Views
240
Replies
7
Views
145
Replies
8
Views
371
Replies
22
Views
304
Replies
0
Views
90

1,196,516
Messages
6,015,679
Members
441,915
Latest member
sm Hussaini

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back