VBA to allow user to run through userform again

grumpygnome

New Member
Joined
Aug 29, 2016
Messages
2
Hi! I'm a novice user to VBA; I really appreciate any help.

I'm working with a userform; I've got a 'complete' button that transfer the textbox entries to specific cells on the worksheet. However, I also need to allow the user to hit the 'add another region' button and then be able to go back through the form again to enter additional information. This would then transfer the additional info to a new line on the worksheet.

I think I need a loop, yes?

Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You have to share your userform code so that we can look into it. Usually we use unload to close the usreform If you comment out that line it should just leave the userfom on screen.
 
Upvote 0
My apologies! Your comment helped, it got me thinking in the right direction.

I'm now closing out the transferring the data and opening the userform again for new entry. Here's my code, it's working but I'm open to suggestions if you feel there is a better way:

Code:
Private Sub AddAnother_Click()
'Allow user to enter another peril


If Peril.Text = ("Earthquake") Then
    Sheets("LMRT").Range("C57") = Region.Text
    Sheets("LMRT").Range("D57") = Limit.Text
    Sheets("LMRT").Range("E57") = ExcessOf.Text
    Sheets("LMRT").Range("F57") = AGCSShare.Text
End If


If Peril.Text = ("Earthquake SL") Then
    Sheets("LMRT").Range("C58") = Region.Text
    Sheets("LMRT").Range("D58") = Limit.Text
    Sheets("LMRT").Range("E58") = ExcessOf.Text
    Sheets("LMRT").Range("F58") = AGCSShare.Text
End If


If Peril.Text = ("Windstorm") Then
    Sheets("LMRT").Range("C59") = Region.Text
    Sheets("LMRT").Range("D59") = Limit.Text
    Sheets("LMRT").Range("E59") = ExcessOf.Text
    Sheets("LMRT").Range("F59") = AGCSShare.Text
End If

Unload Me
CATAccountReinsurance.Show
 
Upvote 0
That is easy an simple way to do it so why trying to find another solution :) Just unload and show it again do the trick . You could add a Msgbox in between unload and shopw so users know that they have successfully enterd the data and they are going to add new one.

Also you will could add new button "Exit" to close userform once all is done
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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