Question

VBA LOOPS The two macros in this homework should be assigned to separate buttons and should...

VBA LOOPS

The two macros in this homework should be assigned to separate buttons and should be located on the same worksheet.

When you are done, upload your saved workbook below.

Be sure to write your code in a module in the workbook you will submit, not in your personal workbooks or sheets. To access the correct module, go to your “Visual Basic,” right-click “Microsoft Excel Objects” in the workbook you are submitting, and then click “Insert” and “Module.”

Problem 1: Write a Sub that prints out numbers 1 through 25 in an Excel worksheet using any type of Loop (e.g., Do Until, Do While, For).

Problem 2: Create a nested-loop program (you can use any type of loop you would like).

This nested loop should take the names input (below) and print out every possible combination of first and middle names. These input names will need to appear in your workbook somewhere. Then, output every possible combination of first and middle names somewhere in the worksheet. Your program should work correctly with more or less first names and middle names. Below is an example of input and output. To save space, only the names associated with the first two first names are shown in the example output.

Input

First names Middle names
Penelope Jill
Gwyneth Diane
Alice Heidi
Anna Lilly
Victoria

Example Output

First names Middle names
Penelope Jill
Penelope Diane
Penelope Heidi
Penelope Lilly
Penelope Victoria
Gwyneth Jill
Gwyneth Diane
Gwyneth Heidi
Gwyneth Lilly
Gwyneth Victoria
etc. etc.

Homework Answers

Answer #1

Problem 1:

Sub Button1_Click()
' Generating numbers from 1 to 25
' Using For loop
For i = 1 To 25
' Writing data to Cell
Cells(i, 1).Value = i
Next i
End Sub

Sample Run:

_________________________________________________________________________________________

Problem 2:

Sub Button2_Click()
' Prints the combination of First and Last names
  
' Declaring Variables
Dim first, last As String
Dim k As Integer
k = 3
  
' Looping over first names
For i = 3 To 6
'Fetching first name
first = Cells(i, 7).Value
' Looping over Last names
For j = 3 To 7
'Fetching last name
last = Cells(j, 8).Value
'Printing into another cells
Cells(k, 10).Value = first
Cells(k, 11).Value = last
k = k + 1
Next j
Next i
End Sub

Sample Run:

Know the answer?
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
Similar Questions
Assignment goals • Build experience solving problems by implementing branch and loop algorithms. • Become able...
Assignment goals • Build experience solving problems by implementing branch and loop algorithms. • Become able to program using control structures. • Understand and implement string comparison in Java. • Develop skills required to write and debug Java programs. Description You program must start and keep dialog with the user. Please create the first prompt for the dialog. After that your program must accept the user’s response and echo it (output to screen) in upper case and adding the question...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings....
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings. You must base your code on the doubly linked list implementation given in my Week 8 slides. Change the code so that instead of an ‘int’ each node stores a string (choose a suitable size). Each node should also have a next node pointer, and previous node pointer. Then write functions to implement the following linked list operations: • A printList function that prints...
Dice Rolling) Write an application to simulate the rolling of two dice. The application should use...
Dice Rolling) Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the...
In this assignment you will analyze the performance of actual company divisions. FASB ASC 280 (formerly...
In this assignment you will analyze the performance of actual company divisions. FASB ASC 280 (formerly SFAS 131) requires publicly traded companies to disclose segment information in the notes to the financial statements. You will use Excel to create visually appealing data tables and bar charts to analyze division performance, and then comment on the results.    Due Date: Tuesday, May 1, 2018.   Submit as an attachment in Blackboard in the Module 24 Assignment. SECTION I The link is to...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
JAVA: MUST BE DONE IN JAVA Assignment: Write algorithms and programs to play “non-betting” Craps. Craps...
JAVA: MUST BE DONE IN JAVA Assignment: Write algorithms and programs to play “non-betting” Craps. Craps is a game played with a pair of dice. In the game, the shooter (the player with the dice) rolls a pair of dice and the number of spots showing on the two upward faces are added up. If the opening roll (called the “coming out” roll) is a 7 (“natural”) or 11 (“yo-leven”), the shooter immediately wins the game. If the coming out...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT