• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Add message to choose file to load [SOLVED]

brightyoyo

New Member
Hi


I have a macro that will import data from another file into the opened workbook. The only problem is a have to include the path too the file. Is there a way to create a prompt to ask me where the file to import is located. Here a sample of the macro


Code:
Dim wb As Workbook

[code]Set wb = ThisWorkbook

[code]Workbooks.Open Filename:="WORKSTATION-48New FolderNew Files

[code]Template.xlsx" '<<<< Change File Name

[code]Columns("B:B").Select

Selection.Copy

wb.Activate[/code]

Range("D1").Select[/code]

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _[/code]

False, Transpose:=False[/code]


Thank You
 
Hi Brightyoyo..


I think.. it will be better if you not asked fro msgbox (we called it InputBox :) and BROWSE option is better in this case..

[pre]
Code:
Dim wb As Workbook
Set wb = ThisWorkbook
Filename = Application.GetOpenFilename("Excel Files (*.XLS*), *.XLS*")
If Filename <> False Then
Workbooks.Open Filename
Columns("B:B").Select
Selection.Copy
wb.Activate
Range("D1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End If
[/pre]

Regards,

Deb
 
Back
Top