Question

Excel

develop a VBA program that will read in the values of m and n and then generate and output an m by n matrix [A]. dij :i- j st

0 0
Add a comment Improve this question Transcribed image text
Answer #1

VBA code (with comments) for the problem:

Sub makeArray()
'Declarations of variables
Dim m As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
'Declaration of dynamic array mat()
Dim mat() As Integer
'Take user input for m rows an n columns
m = InputBox("Enter number of rows: ", "Input", 6)
n = InputBox("Enter number of columns: ", "Input", 3)
'Redimension mat with user given value
ReDim mat(m, n) As Integer
'assign value to matrix by formula a(i, j) = i-j
For i = 1 To m
For j = 1 To n
mat(i, j) = i - j
'start writing from Cell(5, 1)
Cells(i + 4, j).Value = mat(i, j)
Next j
Next i
End Sub

OUTPUT:

A B с D E 1 2 3 4 5 0 -1 -2 6 1 0 7 2 1 -1 0 1 8 3 2 9 4 3 2 10 5 4 3 11

Add a comment
Know the answer?
Add Answer to:
Excel develop a VBA program that will read in the values of m and n and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Homework 06b For...Next Statements The elements of a Hilbert matrix are given by the formula bu=1/(i+j-1),...

    Homework 06b For...Next Statements The elements of a Hilbert matrix are given by the formula bu=1/(i+j-1), where į and j are the row and column indices of the matrix. For example, the 5x5 Hilbert matrix is: [ 1 172 1/3 1/4 175 172 173 174 175 176 173 174 175 176 177 174 175 176 177 178 175 176 177 178 179 Write a Sub that writes the elements of a mxm Hilbert matrix on an Excel spreadsheet, where m...

  • can someone please help me out with this? i have to write this in vba excel....

    can someone please help me out with this? i have to write this in vba excel. Question 2: (40 Pointsy) The total cnerey, E. ofa movins hint i comual to energy, E, of a moving object is equal to the sum of its kinetic and potential energieS: where m is the mass (in kg) v is the velocity (in m/s) h is the height of the object (in m) g is the acceleration due to gravity (9.81 m/s') 5 m/s...

  • Let M be an n x n matrix with each entry equal to either 0 or 1. Let mij denote the entry in row i and column j. A diago...

    Let M be an n x n matrix with each entry equal to either 0 or 1. Let mij denote the entry in row i and column j. A diagonal entry is one of the form mii for some i. Swapping rows i and j of the matrix M denotes the following action: we swap the values mik and mjk for k = 1,2, ... , n. Swapping two columns is defined analogously. We say that M is rearrangeable if...

  • I need this problem to be solved in Excel VBA code. Need full code in VBA....

    I need this problem to be solved in Excel VBA code. Need full code in VBA. Please solve 1st Task : '5 or 0'. Please help me urgently with proper answer and coding solutions which I can run in Excel/vba. Thanks Course: Programming languages Second laboratory work File and string processing Create a program that processes text file according to task variant. Requirements: 1. Create text file (use notepad) with some lines of data according to task variant. 2. Ask...

  • A matrix with dimensions m by n, where m > n, has fewer rows than columns.

    Enter T or F depending on whether the statement is true or false. (Only ONE attempt allowed.) (You must enter Tor F -- True and False will not work.)_______  1. A matrix with dimensions m by n, where m > n, has fewer rows than columns._______  2. The 3rd row, 4th column entry of a matrix is below and to the right of the 2nd row, 3rd column entry.

  • Bonus 1 • Write a java program to transpose a matrix mat[N][M], where: 1) You ask...

    Bonus 1 • Write a java program to transpose a matrix mat[N][M], where: 1) You ask the user to input N and M 2) You then ask the user to input the matrix row by row 3) You transpose the matrix 4) You output the transpose to the user

  • Develop an Excel spreadsheet model to calculate the values of European call and put option using...

    Develop an Excel spreadsheet model to calculate the values of European call and put option using the Black-Sholes formulas! (See formulas 3.17 and 3.18 on page 48 in the textbook. Note log means natural logarithm in the formulas of the textbook!) Use the following data as inputs: the stock price $92.00, the volatility is σ = 0.34, riskfree annual interest rate r = 2.5%, exercise price E = $100, time to expiration is 0.4 years. How to build the spreadsheet...

  • DESCRIPTION Complete the program using Java to read in values from a text file. The values...

    DESCRIPTION Complete the program using Java to read in values from a text file. The values will be the scores on several assignments by the students in a class. Each row of values represents a specific student's scores. Each column represents the scores of all students on a specific assignment. So a specific value is a specific student's score on a specific assignment. The first two values in the text file will give the number of students (number of rows)...

  • I want to change this C code so that instead of prompting the user to enter...

    I want to change this C code so that instead of prompting the user to enter the argument value, or requiring the argument be entered after by pressing the “enter” key, instead I want the code changed so that the program opens a file, (which include the input values) read in the elements and pass in the input file as a command line argument. (the input file includes the size of the matrix and the matrix values) Here's an example...

  • C++ , no ptrs or struct Solve a system of equations using the Gaussian Elimination technique....

    C++ , no ptrs or struct Solve a system of equations using the Gaussian Elimination technique. The matrix will be 10X10 or smaller and will contain floats. Then read in the matrix. Then read in the original answer column (see below for example). Then using the element location 1,1 of the matrix (note I am using the mathematics convention of starting numbering at 1), you will change row 1 and also eliminate the other elements in column 0 using Gaussian...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT