ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Choose (open) workbook for actions on user prompt (https://www.excelbanter.com/excel-programming/361578-choose-open-workbook-actions-user-prompt.html)

erikhs[_7_]

Choose (open) workbook for actions on user prompt
 

Hello,

The headline might not be very descriptive. My question is:
How can i get excel to recognize or let user choose, which open
workbook to process with macro, if this workbook has differing name
from time to time.
The macro now uses the "open" function, to open a workbook of choice
and then perform actions, however i i want a different action
performed(all is in user forms), i must close the workbook again. How
can i give the user the option to choose an open workbook/window while
in a sort of user form? I do not wish for something where the user has
to select a cell in the workbook and then run macro, but rather run
userform then select.

Thank You!


--
erikhs
------------------------------------------------------------------------
erikhs's Profile: http://www.excelforum.com/member.php...o&userid=32788
View this thread: http://www.excelforum.com/showthread...hreadid=542427


Ardus Petus

Choose (open) workbook for actions on user prompt
 
Create an Userform (UserForm1)
Add a ListBox (ListBox1)
Add a Command Button (CommandButton1) with caption "OK"

Paste the following code in Userform code:

'------------
Private Sub CommandButton1_Click()
MsgBox ListBox1.Value
End Sub

Private Sub UserForm_Initialize()
Dim wb As Workbook
With ListBox1
For Each wb In Workbooks
If wb.Name < ThisWorkbook.Name Then
.AddItem (wb.Name)
End If
Next wb
.ListIndex = 1
End With
End Sub
'---------------------

Et voilà!

HTH
--
AP

"erikhs" a écrit dans
le message de news: ...

Hello,

The headline might not be very descriptive. My question is:
How can i get excel to recognize or let user choose, which open
workbook to process with macro, if this workbook has differing name
from time to time.
The macro now uses the "open" function, to open a workbook of choice
and then perform actions, however i i want a different action
performed(all is in user forms), i must close the workbook again. How
can i give the user the option to choose an open workbook/window while
in a sort of user form? I do not wish for something where the user has
to select a cell in the workbook and then run macro, but rather run
userform then select.

Thank You!


--
erikhs
------------------------------------------------------------------------
erikhs's Profile:
http://www.excelforum.com/member.php...o&userid=32788
View this thread: http://www.excelforum.com/showthread...hreadid=542427




erikhs[_8_]

Choose (open) workbook for actions on user prompt
 

Thank you!

I will try this when i get the time.


--
erikhs
------------------------------------------------------------------------
erikhs's Profile: http://www.excelforum.com/member.php...o&userid=32788
View this thread: http://www.excelforum.com/showthread...hreadid=542427



All times are GMT +1. The time now is 03:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com