Advertisement
Guest User

Untitled

a guest
Feb 4th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VisualBasic 0.62 KB | Source Code | 0 0
  1. '-----Workbook A-----'
  2. Option Explicit
  3.  
  4. Private Sub Workbook_Open()
  5.  
  6. Application.Visible = False
  7. ThisWorkbook.Activate
  8. Dim wb As Workbook
  9.  
  10. For Each wb In Workbooks
  11.     If wb.Name = "WorkbookB.xlsm" Then
  12.         wb.Close xlDoNotSaveChanges
  13.     End If
  14. Next wb
  15.  
  16. Call UserForm1.Show
  17.  
  18. End Sub
  19.  
  20. '-----Userform1-----'
  21. Option Explicit
  22.  
  23. Private Sub CommandButton1_Click()
  24.     Application.Visible = True
  25.     UserForm1.Hide
  26. End Sub
  27.  
  28. Private Sub CommandButton2_Click()
  29.     TextBox1.Value = Sheets("SheetA").Range("A1")
  30. End Sub
  31.  
  32. Private Sub UserForm_Initialize()
  33.  
  34.     Application.Visible = False
  35.    
  36. End Sub
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement