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
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top