Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function WorksheetExists(sName As String) As Boolean
- WorksheetExists = Evaluate("ISREF('" & sName & "'!A1)")
- End Function
- Sub Find_Personal_Macro_Workbook()
- ' Generates the file path for the Personal_Macro_Workbook in Windows
- ' Inserts path on new sheet placed at the beginning of the workbook
- '
- Dim path As String
- path = Application.StartupPath
- If (WorksheetExists("path_to_Personal_XLSB")) Then
- Range("A1").Select
- Selection.EntireRow.Insert
- ActiveSheet.Range("$A$1").Value = "path:"
- ActiveSheet.Range("$B$1").Value = path
- Else
- Sheets.Add Before:=ActiveSheet
- ActiveSheet.Name = "path_to_Personal_XLSB"
- ActiveSheet.Range("$A$1").Value = "path:"
- ActiveSheet.Range("$B$1").Value = path
- End If
- ' Alternative Placement:
- '
- ' Add Path in current sheet
- ' by inserting a new line at the top row of the current worksheet
- ' and inserting the file path to the first cell
- '
- ' Range("A1").Select
- ' Selection.EntireRow.Insert
- ' Range("A1") = "path:"
- ' Range("B1") = path
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement