Guest User

Untitled

a guest
Jan 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Sub GetSheetnames()
  2. 'Turn off alerts
  3. Application.DisplayAlerts = False
  4.  
  5. 'Open the Workbook that i want to look for the worksheet names this
  6. 'white book template is a save as copy of another file as it makes it
  7. 'easier to reference as I work with 1000's of file with same format but
  8. 'are all saved as a different name
  9.  
  10. Workbooks.Open Filename:="D:ProjectsASE TemplatesASE Template White
  11. Book.xlsx"
  12. Dim ws As Worksheet
  13. Dim i As Integer
  14. With ThisWorkbook.Worksheets("Tab Names from white book")
  15. .Range("A:A").ClearContents
  16. For Each ws In ActiveWorkbook.Worksheets
  17. i = i + 1
  18. .Range("A" & i) = ws.Name
  19.  
  20. Next ws
  21.  
  22. End With
  23.  
  24. Workbooks("ASE Template White Book.xlsx").Close
  25.  
  26. Application.DisplayAlerts = True
  27.  
  28. End Sub
  29.  
  30. With ThisWorkbook.Worksheets("Tab Names from white book")
  31. .Range("A:A").ClearContents
  32. For Each ws In ActiveWorkbook.Worksheets
  33. i = i + 1
  34. .Range("A" & i) = ws.Name
  35.  
  36. Next ws
  37.  
  38. With ThisWorkbook.Worksheets("Tab Names from white book")
  39. .Range("B:B").ClearContents
  40. For Each ws In ActiveWorkbook.Worksheets
  41. i = i + 1
  42. .Range("B" & i) = H4.value
  43.  
  44. .Range("B" & i) = Cells(3,8).Value
Add Comment
Please, Sign In to add comment