FalconFlyer

New Member
Joined
May 18, 2015
Messages
30
I have a userform in a workbook A that I can click on a button to open another workbook (B). When I am done editing Workbook B, I want to save and close. Excel will not let me until I close the userform in Workbook A. I want to leave the userform open as I will need it to do other things and has input boxes that I do not want to keep retyping. Is there something specific I should be adding to my code?
TIA



Code:
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim staff_eval As String
Dim emp_name As String
Dim Actsheet As String
Dim LastRow As Long
txt = TextBox1.Text
    staff_eval = "file.xlsm"
    '~~> open the workbook
    Set wb = Workbooks.Open(staff_eval)
    
   
    
    LastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("Summary").Unprotect ""
    Application.ScreenUpdating = False
    On Error Resume Next
    Sheets("Template").Visible = True
    Sheets("Template").Copy _
    after:=Sheets("Template")
    ActNm = ActiveSheet.Name
    ActiveSheet.Name = txt
    Sheets(ActiveSheet.Name).Visible = True
    ActiveWorkbook.Sheets("Template").Visible = False
    Sheets("Summary").Range("A" & (LastRow + 1)).Value = ActiveSheet.Name
    Sheets("Summary").Protect ""
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Make your form modeless when you load it:
Code:
frmMyForm.Show vbModeless
 
Upvote 0

Forum statistics

Threads
1,221,527
Messages
6,160,342
Members
451,638
Latest member
MyFlower

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