Browse file and open...

Rondy013

New Member
Joined
Apr 8, 2013
Messages
6
Hi, I'm a newbie here and I face problem creating the file browsing macro.
The required process is:
1. Click button
2. Pop up with file browsing window (to search to computer directories)
3. Select file types
4. Select file
5. "OK" to open

Hope to get helps on this.
Thanks in advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Code:
Sub GetFile()
    Dim MyPath As String
    Dim FName As Variant
    Dim sh As Worksheet
    Dim ThisBk As String
    
    'Set a dialog for opening folder and select single file
    MyPath = Application.DefaultFilePath
    FName = Application.GetOpenFilename(MultiSelect:=False)
    ThisBk = ThisWorkbook.Name
                                          
    If FName = False Then
        MsgBox ("Please select a file")
    Else
        Workbooks.Open (FName)
    End if
End Sub
 
Upvote 0
For text files, this will work, but it does depend on what file type you're looking for.

Code:
Fname = Application.GetOpenFilename("Text Files (*.txt), *.txt")
 
Upvote 0
Thanks rjwebgraphix.

I got coloumn of numbers now and I would like to copy each number to paste in other sheet in the same file.
precedure is:
1. Content is 0 then got to upper cell
2. Content is not equal to 0 then copy and paste to next sheet
How to construct this "if" condition?
 
Upvote 0
Hi i have below commands:
Range("Y52").Select
ActiveCell.FormulaR1C1 = "5V"
Sheets("StandardTemplate (2)").Select
Sheets("StandardTemplate (2)").Name = "5V"
Range("E1").Select
ActiveSheet.Paste

The content inside range("Y52") isn't the same everytime and want to copy the content of this range to other location.
How to make it copy content only? In this command it is fix to be "5V" even the content inside the range is not "5V".
 
Upvote 0

Forum statistics

Threads
1,203,620
Messages
6,056,335
Members
444,861
Latest member
B4you_Andrea

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