VBA PROGRAM - How to open another excel file and use it

bdaniel2

New Member
Joined
Dec 21, 2017
Messages
15
Hello, I'm a little bit new with all the VBA thing but I have the basic. I new other programs languages.

So my question:

if I would like to give the member that using the VBA MACRO code to open another excel file somewhere at his computer and after that the macro will do everything how do I do that?

(I mean only to ask the costumer to open the file I'm asking)

thanks,
Daniel.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi & welcome to the board.
How about
Code:
Sub OpenFile()

    Dim Fname As String
    Dim Wbk As Workbook
    
    Fname = Application.GetOpenFilename(FileFilter:="xls Files (*.xls*), *.xls*", Title:="Select a file", MultiSelect:=False)
    If Fname = "False" Then
        MsgBox "no file selected"
        Exit Sub
    Else
        Set Wbk = Workbooks.Open(Fname)
        ' Your code here
        Wbk.Close , True
    End If
End Sub
 
Upvote 0
hello, I need some help.

so if I opened the other file like you explain me before and now I would like to work with both of the files(the first file and the file I opened with your code after been at the first file.)
how do I make rotation with both of them? like example i got two excel files : file1 and file2

if first i need to copy a number from file1 and search the number at file2 and after i search it and found the number i searched i would like to copy something from his own row and after that i want to go to- file1 and to paste the information i copied.

sorry for the example and i hope you understand it.

thank you very much,
Daniel.
 
Upvote 0
Something like this
Code:
Sub OpenFile()

    Dim Fname As String
    Dim OrigWbk As Workbook
    Dim NewWbk As Workbook
    Dim Fnd As Range
    
    Set OrigWbk = ThisWorkbook
    Fname = Application.GetOpenFilename(FileFilter:="xls Files (*.xls*), *.xls*", Title:="Select a file", MultiSelect:=False)
    If Fname = "False" Then
        MsgBox "no file selected"
        Exit Sub
    Else
        Set NewWbk = Workbooks.Open(Fname)
        
        Set Fnd = NewWbk.Sheets("Sheet1").Range("A:A").Find(OrigWbk.Sheets("Sheet1").Range("A1").Value, , , xlWhole, , , False, , False)
        ' Your code here
        NewWbk.Close , True
    End If
End Sub
 
Upvote 0
hello my friend.
i have a problem in the excel. I am trying to insert charts & graphs. I will attach to this message example.
i want to create charts like the same one at the picture.
if you can see at the chart: the blue : CT in Calendar Days it is the : ACT and the orange: is target

please help me because i am trying to create new charts up to date but i did not make it.
Capture.png
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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