PC Review


Reply
Thread Tools Rate Thread

Activate Workbook via UserForm/Listbox ???

 
 
Paige
Guest
Posts: n/a
 
      23rd Jun 2009

I have the following code that when the main user form initializes, it fills
a listbox with the names of all open workbooks and also activates a specifc
workbook/sheet/cell. Problem is that in order for the user to be able to
change the auto-selected cell, they have to highlight the workbook in the
listbox first and then use an associated refedit on the same form; i.e., they
can't just move their cursor on the sheet (essentially working 'behind' the
userform) to select another cell, like other forms/refedits/listboxes that I
have....even tho the code is the same (except the other code does not have
the last 3 lines). Am sure it has to do with the fact that my code to
activate/select is not right. Can someone advise what I'm doing wrong
please?

Private Sub UserForm_Initialize()
Dim wb As Workbook
Application.ScreenUpdating = True
For Each wb In Workbooks
SelectFormulaCellWorkbook.AddItem wb.Name
Next
Workbooks(LookupValuesWBName).Activate
Worksheets(LookupValuesSheetName).Select
Range(LookupValuesCellAddress).Select
End Sub

 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      23rd Jun 2009

the userform defaults to "modal" which locks the apllication

if you change the calling code to modeless, your user can select a cell and
change worksheets - essentially the form doesn't have any lock on excel

UserForm1.Show vbModeless



"Paige" <(E-Mail Removed)> wrote in message
news:70DCA10E-A509-4389-BB50-(E-Mail Removed)...
> I have the following code that when the main user form initializes, it
> fills
> a listbox with the names of all open workbooks and also activates a
> specifc
> workbook/sheet/cell. Problem is that in order for the user to be able to
> change the auto-selected cell, they have to highlight the workbook in the
> listbox first and then use an associated refedit on the same form; i.e.,
> they
> can't just move their cursor on the sheet (essentially working 'behind'
> the
> userform) to select another cell, like other forms/refedits/listboxes that
> I
> have....even tho the code is the same (except the other code does not have
> the last 3 lines). Am sure it has to do with the fact that my code to
> activate/select is not right. Can someone advise what I'm doing wrong
> please?
>
> Private Sub UserForm_Initialize()
> Dim wb As Workbook
> Application.ScreenUpdating = True
> For Each wb In Workbooks
> SelectFormulaCellWorkbook.AddItem wb.Name
> Next
> Workbooks(LookupValuesWBName).Activate
> Worksheets(LookupValuesSheetName).Select
> Range(LookupValuesCellAddress).Select
> End Sub
>

 
Reply With Quote
 
Paige
Guest
Posts: n/a
 
      23rd Jun 2009

Patrick, thanks. Did not have luck with this or the ShowModal property -
just hosed Excel up - maybe because there is a refedit in the userform.
Anyway, muddled around a bit more and added some code to the
userform_initialize sub, setting the focus back to the refedit, and that
seems to be working (for now at least)!

"Patrick Molloy" wrote:

> the userform defaults to "modal" which locks the apllication
>
> if you change the calling code to modeless, your user can select a cell and
> change worksheets - essentially the form doesn't have any lock on excel
>
> UserForm1.Show vbModeless
>
>
>
> "Paige" <(E-Mail Removed)> wrote in message
> news:70DCA10E-A509-4389-BB50-(E-Mail Removed)...
> > I have the following code that when the main user form initializes, it
> > fills
> > a listbox with the names of all open workbooks and also activates a
> > specifc
> > workbook/sheet/cell. Problem is that in order for the user to be able to
> > change the auto-selected cell, they have to highlight the workbook in the
> > listbox first and then use an associated refedit on the same form; i.e.,
> > they
> > can't just move their cursor on the sheet (essentially working 'behind'
> > the
> > userform) to select another cell, like other forms/refedits/listboxes that
> > I
> > have....even tho the code is the same (except the other code does not have
> > the last 3 lines). Am sure it has to do with the fact that my code to
> > activate/select is not right. Can someone advise what I'm doing wrong
> > please?
> >
> > Private Sub UserForm_Initialize()
> > Dim wb As Workbook
> > Application.ScreenUpdating = True
> > For Each wb In Workbooks
> > SelectFormulaCellWorkbook.AddItem wb.Name
> > Next
> > Workbooks(LookupValuesWBName).Activate
> > Worksheets(LookupValuesSheetName).Select
> > Range(LookupValuesCellAddress).Select
> > End Sub
> >

 
Reply With Quote
 
norie
Guest
Posts: n/a
 
      24th Jun 2009
Did you ever consider using Application.Goto...?

Option Explicit

Private Sub SelectFormulaCellWorkbook_Click()

Application.Goto Workbooks
(SelectFormulaCellWorkbook.Value).Worksheets(1).Range("A1"),
Scroll:=True

End Sub

Private Sub UserForm_Initialize()
Dim wb As Workbook

Application.ScreenUpdating = True
For Each wb In Workbooks
SelectFormulaCellWorkbook.AddItem wb.Name
Next

End Sub

On Jun 23, 8:56*pm, Paige <Pa...@discussions.microsoft.com> wrote:
> Patrick, thanks. *Did not have luck with this or the ShowModal property-
> just hosed Excel up - maybe because there is a refedit in the userform. *
> Anyway, muddled around a bit more and added some code to the
> userform_initialize sub, setting the focus back to the refedit, and that
> seems to be working (for now at least)! *
>
>
>
> "Patrick Molloy" wrote:
> > the userform defaults to "modal" which locks the apllication

>
> > if you change the calling code to modeless, your user can select a celland
> > change worksheets - essentially the form doesn't have any lock on excel

>
> > * UserForm1.Show vbModeless

>
> > "Paige" <Pa...@discussions.microsoft.com> wrote in message
> >news:70DCA10E-A509-4389-BB50-(E-Mail Removed)...
> > > I have the following code that when the main user form initializes, it
> > > fills
> > > a listbox with the names of all open workbooks and also activates a
> > > specifc
> > > workbook/sheet/cell. *Problem is that in order for the user to be able to
> > > change the auto-selected cell, they have to highlight the workbook inthe
> > > listbox first and then use an associated refedit on the same form; i.e.,
> > > they
> > > can't just move their cursor on the sheet (essentially working 'behind'
> > > the
> > > userform) to select another cell, like other forms/refedits/listboxesthat
> > > I
> > > have....even tho the code is the same (except the other code does nothave
> > > the last 3 lines). *Am sure it has to do with the fact that my codeto
> > > activate/select is not right. *Can someone advise what I'm doing wrong
> > > please?

>
> > > Private Sub UserForm_Initialize()
> > > Dim wb As Workbook
> > > Application.ScreenUpdating = True
> > > For Each wb In Workbooks
> > > * SelectFormulaCellWorkbook.AddItem wb.Name
> > > Next
> > > Workbooks(LookupValuesWBName).Activate
> > > Worksheets(LookupValuesSheetName).Select
> > > Range(LookupValuesCellAddress).Select
> > > End Sub- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill userform textbox from userform listbox clik event GregJG Microsoft Excel Programming 1 7th Dec 2008 02:05 PM
userform listbox cannot get listbox.value to transfer back to main sub malosky2@msn.com Microsoft Excel Programming 1 17th May 2006 09:44 PM
Workbook.Activate / Window.Activate problem Tim Microsoft Excel Programming 3 3rd Feb 2006 11:38 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com Microsoft Excel Programming 3 6th May 2005 05:44 PM
Calling a Personal.XLS Sub from anther workbook's 'This Workbook' Sheet Activate Jack Gillis Microsoft Excel Discussion 2 21st Mar 2005 11:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:41 PM.