Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new to vba

Status
Not open for further replies.

scottscott

Programmer
Dec 14, 2006
29
US
I am new to vba but familiar with various other programming languages like C++, assembly. I was wondering how i would go about making a browse button in an excel sheet that opens a file that the user would select, copies the data(columns A-E), pastes the data in the current excel sheet, and closes the file from which the data was copied. Any help would be greatly appreciated, thanks.
 
Turn on the macro recorder and record all the steps. The code it creates is somewhat messy but it will get you started.
 
That would work, but i do not want the macro to open the same file each time. Currently i have a menu called, update device, then one option called process devices. Once process devices is selected a dialog box is opened which displays a blank text box and a browse button. How do link the browse button so that it opens the file so that i may copy it?
 
The command I use for letting people navigate to a particular file is the GetOpenFileName Method. Have a look at the help for it.

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Code:
Sub UserFileSelect()
Sub UserFileSelect()

Dim vFile As Variant
     
    vFile = Application.GetOpenFilename _
    (FileFilter:="Excel (*.xls),*.xls", _
    Title:="Select Excel File", MultiSelect:=False)
      
If vFile = False Then Exit Sub
    
Workbooks.Open vFile

End Sub
 
Is the GetOpenFileName function defined in excel 2002?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top