SHARE
TWEET

Untitled

a guest Oct 17th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function WorksheetExists(sName As String) As Boolean
  2.     WorksheetExists = Evaluate("ISREF('" & sName & "'!A1)")
  3. End Function
  4.  
  5.  
  6. Sub Find_Personal_Macro_Workbook()
  7.  
  8. '   Generates the file path for the Personal_Macro_Workbook in Windows
  9. '   Inserts path on new sheet placed at the beginning of the workbook
  10. '
  11.  
  12.     Dim path As String
  13.  
  14.     path = Application.StartupPath
  15.    
  16.        
  17.     If (WorksheetExists("path_to_Personal_XLSB")) Then
  18.         Range("A1").Select
  19.         Selection.EntireRow.Insert
  20.         ActiveSheet.Range("$A$1").Value = "path:"
  21.         ActiveSheet.Range("$B$1").Value = path
  22.     Else
  23.         Sheets.Add Before:=ActiveSheet
  24.         ActiveSheet.Name = "path_to_Personal_XLSB"
  25.         ActiveSheet.Range("$A$1").Value = "path:"
  26.         ActiveSheet.Range("$B$1").Value = path
  27.     End If
  28.    
  29.    
  30. '   Alternative Placement:
  31. '
  32. '    Add Path in current sheet
  33. '    by inserting a new line at the top row of the current worksheet
  34. '    and inserting the file path to the first cell
  35. '
  36. '    Range("A1").Select
  37. '    Selection.EntireRow.Insert
  38. '    Range("A1") = "path:"
  39. '    Range("B1") = path
  40.  
  41. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top