Macro to select a file path from desktop

witsonjoyet

Board Regular
Joined
Sep 13, 2013
Messages
99
Good Day,

I have a macro which useful for creating a dashboard. Now the problem is i have to send that excel sheet to my boss. Whenever i send to these macro enabled excel sheets to my boss it does not work properly at my boss system. Problem is the path. For example in my macro its like the following

Sub OpenImp()
Dim owb As Workbook
Dim sh As Worksheet
Dim lr As Long
Dim rng As Range
Dim msgb As String

msgb = MsgBox("Do You Wanna import Daily Turnover Data?", vbYesNo, "Question?")
If msgb = vbYes Then
Set sh = Sheet2
Set owb = Workbooks.Open("C:\Documents and Settings\SYSTEM2\Desktop\book1.xlsx")

lr = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Union(Range("A2:C" & lr), Range("F2:K" & lr))
rng.Copy sh.Range("A" & Rows.Count).End(xlUp)(2)
owb.Close False 'Close opened workbook don't save
End If
End Sub


every time i have to change this path (Red font in above) . Is there any way to save this macro on desktop automatically in any system?

Please suggest me
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Watch MrExcel Video

Forum statistics

Threads
1,122,193
Messages
5,594,774
Members
413,934
Latest member
austinb

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