Sheet Focus

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
I'm using a Userform.show vbmodeless to float above the worksheet I'm using. I'm having to utilize form buttons to interact/transfer data between one workbook and another and I sometimes click between the sheets.
THE PROBLEM:
Sometimes when I click on one workbook's sheet, it seems to think it is still on there other sheet. I have to close the Userform to regain proper focus. What can I do? Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Does the code turn ScreenUpdating off?
 
Upvote 0
Does the code turn ScreenUpdating off?

Yes, but I turn it back on after the process

Code:
Application.ScreenUpdating = True
Application.StatusBar = False
Application.Calculation = xlCalculationAutomatic


UserForm1.TextBox1.BackColor = vbGreen
UserForm1.Repaint
UserForm1.TextBox1 = "Group " & UserForm1.Tag & "ed"
UserForm1.CommandButton5.Tag = "" 'reset selection
UserForm1.Repaint
AppActivate wwbk.Application
Windows(wwsh.Parent.Name).Activate
wwbk.Activate
wwsh.Activate
wwsh.Select
wwsh.Range("A2").Select 'force selection
Application.Goto reference:=wwsh
selrng = ColLetterFromNo(selcol)
selrng = selrng & 3 & ":" & selrng & 10000
Sheet2.Range(selrng) = "" 'reset
UserForm1.TextBox1 = doapp & " rows copied to " & wwbk.Name & "[" & wwsh.Name & "]"
UserForm1.TextBox1.BackColor = vbGreen
 
Upvote 0
Sorry, I should have been more specific. Do you turn screenupdating off in the Intialize of activate events of the userform?
 
Upvote 0
No, but that could have caused the problems.

Is it the code that is writing info to the wrong sheet/workbook?
 
Upvote 0
No, but that could have caused the problems.

Is it the code that is writing info to the wrong sheet/workbook?

No, it just selects cells on one sheet while the cursor moves around in cells on the other sheet.

I think I fixed it with this:
Code:
AppActivate wwbk.Application
Windows(wwsh.Parent.Name).Activate
wwbk.Activate
wwsh.Activate
wwsh.Select
wwsh.Range("A2").Select 'force selection
Application.Goto reference:=wwsh
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

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