gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,332
- Office Version
- 365
- Platform
- Windows
I have a userform (UserForm45) with a TextBox that copies a range of formulas and then performs a pastespecial in a worksheet. My problem is, the Userform with the TextBox (TextBox42) is launched from a differnt sheet then where the Copy/Paste takes place (Sheet (1)). UserForm45 can be activated from various sheets, so I am using the Set ws = ActiveSheet function to get me back to where I started. The problem is that you can see the sheets change while it performs the code and it looks very unprofessional. How do I keep the original worksheet in view while the code is performed?
Here is the code:
----------------------------------------------------------------------------------
Private Sub TextBox42_Change()
'Identifies the current sheet as ws
Set ws = ActiveSheet
'Code
Sheets("HOURS").Activate
Range("AE3:AE761").Select
Selection.Copy
Range("AD3").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
'Returns to current page after code (the current page could be different depending on where the Userform was launched from
ws.Activate
End Sub
--------------------------------------------------------------------------------
Here is the code:
----------------------------------------------------------------------------------
Private Sub TextBox42_Change()
'Identifies the current sheet as ws
Set ws = ActiveSheet
'Code
Sheets("HOURS").Activate
Range("AE3:AE761").Select
Selection.Copy
Range("AD3").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
'Returns to current page after code (the current page could be different depending on where the Userform was launched from
ws.Activate
End Sub
--------------------------------------------------------------------------------