Loop a Macro-Insert New Data Below Previously Entered Data

Yao567

New Member
Joined
Oct 4, 2013
Messages
4
Basically Once This code ends i make a msgbox asking if you want to run it again. If yes then it runs, but i want to do it infinitely till you tell it no. I think i could do it with do until so I pretty much got that.

This issue is how do I tell it to put the new set of data under the previous. Also not that the original data table range is selected by the user.

Code:
height = InputBox("What is height of theodolite" & height)
distance = InputBox("What is the distance from building" & distance)
theta = InputBox("What is the angle theta" & theta)
Result = BuildingHeight(height, theta, distance)
MsgBox Result
MSG1 = MsgBox("Would you like to print data to worksheet?", vbYesNo)
If MSG1 = vbNo Then
    Exit Sub
    End If
If MSG1 = vbYes Then
    Set MyRange = Application.InputBox("Select Range", Type:=8)
    MyRange.Select
    MyRange.Value = "Height of theolodite"
    ActiveCell.Offset(0, 1) = "Theta"
    ActiveCell.Offset(0, 2) = "Distance to Building"
    ActiveCell.Offset(0, 3) = "Result"
    ActiveCell.Offset(1, 0).Value = height
    ActiveCell.Offset(1, 1).Value = theta
    ActiveCell.Offset(1, 2).Value = distance
    ActiveCell.Offset(1, 3).Value = Result
End If

MSG2 = MsgBox("Would you like to play again", vbYesNo)
Do Until MSG2 = vbNo
Loop
If MSG2 = vbYes Then
 

Forum statistics

Threads
1,082,044
Messages
5,362,855
Members
400,696
Latest member
Kclynn

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top