Problem in using the path that I get from the browser VBA

spin42

New Member
Joined
Aug 28, 2011
Messages
3
Hello

I am using two files which I merge and reformat. My problem is that I am doing something wrong and I cannot use the path from the browser for any other function.

below I have the part of the code that I have the problem


Sub test()


Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName = False Then
' user clicked cancel
Else
MsgBox FName
End If

Dim a As String
a = FName

x=Workbooks(a).Worksheets("Opp Pursuit Detail").Cells(5, 5).Value
'the underlined does not work

End Sub

Is there any other way that I can use the path that I get from the browser to process specific data from the selected file???

Thank you in advance
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You need to open the file

Code:
Sub test()
Dim FName As Variant, x As Variant

Dim wb As Workbook
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName = False Then
    Exit Sub
End If
Set wb = Workbooks.Open(FName)

x = wb.Worksheets("Opp Pursuit Detail").Cells(5, 5).Value

End Sub
 
Upvote 0
does not it open when I write " wb = Workbooks.Open(FName) "
could you give me an example on how you can use the path that you get from the browser to process specific cells???

I am quite newbe..:eeek:
 
Upvote 0
But I have already this line in my code and still I receive an error for the line
x = wb.Worksheets("Opp Pursuit Detail").Cells(5, 5).Value

why?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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