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.
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,384
Office Version
  1. 365
Platform
  1. Windows
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
 

bdaniel2

New Member
Joined
Dec 21, 2017
Messages
15
hey thank you for answering me.
that's looks really good so I will try it.
thank you !
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,384
Office Version
  1. 365
Platform
  1. Windows
Your welcome
 

bdaniel2

New Member
Joined
Dec 21, 2017
Messages
15

ADVERTISEMENT

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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,384
Office Version
  1. 365
Platform
  1. Windows
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
 

bdaniel2

New Member
Joined
Dec 21, 2017
Messages
15

ADVERTISEMENT

thank you my friend!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,384
Office Version
  1. 365
Platform
  1. Windows
Your welcome
 

bdaniel2

New Member
Joined
Dec 21, 2017
Messages
15
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,511
Messages
5,602,081
Members
414,500
Latest member
kevdragon1

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
Top