Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Base 1
  2.  
  3.  
  4. Function addNames()
  5.     Dim gNamesInBook()
  6.     Dim gNamesToAdd()
  7.     Dim tempNameArray()
  8.     Dim namesAdded()
  9.    
  10.     Dim cWorkbookNames As Integer
  11.     Dim cNamesToAdd As Integer
  12.    
  13.     cWorkbookNames = ActiveWorkbook.Names.Count
  14.    
  15.     cNamesToAdd = Sheets("HiddenVariables").Range(Cells(10000, 1).End(xlUp), Cells(2, 1)).Count
  16.    
  17.     ReDim gNamesInBook(cWorkbookNames)
  18.     ReDim gNamesToAdd(cNamesToAdd)
  19.     ReDim tempNameArray(cWorkbookNames)
  20.     'MsgBox UBound(tempNameArray)
  21.    gNamesInBook = gatherNames(gNamesInBook())
  22.    
  23.     namesAdded = addNamesToBook(gNamesInBook())
  24.    
  25.     putGatheredInCells gNamesInBook
  26. End Function
  27.  
  28.  
  29.  
  30. Function gatherNames(ByRef passedArray())
  31.    
  32.     For i = LBound(passedArray) To UBound(passedArray)
  33.         passedArray(i) = _
  34.             ActiveWorkbook.Names(i).Index & ": " & _
  35.             ActiveWorkbook.Names(i).Name & "; \n" & _
  36.             ActiveWorkbook.Names(i).RefersTo & "."
  37.     Next i
  38.    
  39.     gatherNames = passedArray
  40. End Function
  41.  
  42. Sub putGatheredInCells(ByRef passTheNames())
  43.     For i = LBound(passTheNames) To UBound(passTheNames)
  44.         ActiveSheet.Cells(i, 3).Value = passTheNames(i)
  45.     Next i
  46. End Sub
  47.  
  48. Sub selectRange()
  49.     Sheets("HiddenVariables").Range(Cells(10000, 1).End(xlUp), Cells(2, 1)).Select
  50. End Sub
  51.  
  52. Function addNamesToBook(ByRef passTheNames())
  53.     For i = LBound(passTheNames) To UBound(passTheNames)
  54.         pulledName = Left(Split(passTheNames(i), ":"), UBound(passTheNames))
  55.         ActiveWorkbook.Names.Add Name:=pulledName, RefersTo:=pulledReferral
  56.     Next i
  57. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement