Choose File and Use

_eNVy_

Board Regular
Joined
Feb 9, 2018
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hi,

Essentially, every week there is a new file saved (wb1) in a new folder destination within a Network Drive (sadly the filename always changes depending on the date).
This file is then used to populate another (current workbook).

I wish to have the user choose the file (wb1) and upon opening the file, have the code identify the opened file as wb1.

Then I can do simple tasks such as copying data from wb1 into the current workbook.

Is there an easy way of writing this out so that I may easily digest it?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Is this what you're looking for? This function lets users pick a workbook and open it.
VBA Code:
Public Function GetWbk() As Workbook
    Dim oWb         As Workbook
    Dim sWbkName    As String

    sWbkName = Application.GetOpenFilename("Excel Workbooks,*.xlsx;*.xlsm;*.xlsb;*.xls")
    If sWbkName <> "False" Then
        Set oWb = Application.Workbooks.Open(sWbkName)
    End If
    Set GetWbk = oWb
    Set oWb = Nothing
End Function
 
Upvote 0
Solution
Is this what you're looking for? This function lets users pick a workbook and open it.
VBA Code:
Public Function GetWbk() As Workbook
    Dim oWb         As Workbook
    Dim sWbkName    As String

    sWbkName = Application.GetOpenFilename("Excel Workbooks,*.xlsx;*.xlsm;*.xlsb;*.xls")
    If sWbkName <> "False" Then
        Set oWb = Application.Workbooks.Open(sWbkName)
    End If
    Set GetWbk = oWb
    Set oWb = Nothing
End Function

Can this be explained?
Once the file has been opened, I wish to extract information from it.
Where is the definition of the opened file? Is it oWb?
Where would I put my own coding to do the extraction of information?

Thank you for your assistance.
 
Upvote 0
To what extent are you familiar with VBA?
 
Upvote 0
To what extent are you familiar with VBA?
I can do simple tasks but when trying to copy data from the opened worked book - not current, it is not recognising oWb.
I wish for the code to be broken down so that I can fully understand it.
 
Upvote 0
@_eNVy_: Please do not mark a post as the solution that doesn't contain an answer.

Note: Post #2 answers this question. Therefore, it has been marked as the solution to help future readers.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,947
Members
448,534
Latest member
benefuexx

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