Excel VBA Macro: List All Sheet/Tab Names (From Another User Selected Workbook)
Excel VBA Macro: List All Sheet/Tab Names (From Another User Selected Workbook). In this video, we go over how to prompt the user to select another excel file, and then list all of the sheet/tab names in that file.
Code (just realized I never used the "sheet_name" variable. that can be omitted):
Sub tab_names_from_another_wb()
Dim FilePicker As FileDialog
Dim mypath As String
Dim sheet_name As String
Dim sheet_count As Integer
Dim i As Integer
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = ThisWorkbook.Sheets(1)
Set FilePicker = Application.FileDialog(msoFileDialogFilePicker)
With FilePicker
.Title = "Please Select a File"
.ButtonName = "Confirm"
.AllowMultiSelect = False
If .Show = -1 Then
mypath = .SelectedItems(1)
Else
End
End If
End With
ws.Cells.ClearContents
Workbooks.Open Filename:=mypath
sheet_count = Sheets.Count
For i = 1 To sheet_count
ws.Cells(i, 1) = Sheets(i).Name
Next i
ActiveWorkbook.Close savechanges:=False
Application.ScreenUpdating = True
End Sub
#ExcelVBA #ExcelMacro
Видео Excel VBA Macro: List All Sheet/Tab Names (From Another User Selected Workbook) канала greggowaffles
Code (just realized I never used the "sheet_name" variable. that can be omitted):
Sub tab_names_from_another_wb()
Dim FilePicker As FileDialog
Dim mypath As String
Dim sheet_name As String
Dim sheet_count As Integer
Dim i As Integer
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = ThisWorkbook.Sheets(1)
Set FilePicker = Application.FileDialog(msoFileDialogFilePicker)
With FilePicker
.Title = "Please Select a File"
.ButtonName = "Confirm"
.AllowMultiSelect = False
If .Show = -1 Then
mypath = .SelectedItems(1)
Else
End
End If
End With
ws.Cells.ClearContents
Workbooks.Open Filename:=mypath
sheet_count = Sheets.Count
For i = 1 To sheet_count
ws.Cells(i, 1) = Sheets(i).Name
Next i
ActiveWorkbook.Close savechanges:=False
Application.ScreenUpdating = True
End Sub
#ExcelVBA #ExcelMacro
Видео Excel VBA Macro: List All Sheet/Tab Names (From Another User Selected Workbook) канала greggowaffles
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Excel VBA Macro: Open Newest Files (from Multiple Folders) and Save Them in Another Folder](https://i.ytimg.com/vi/a9CZy2xu79M/default.jpg)
![Comment Out Blocks of Code 🤓 #excelmacro #excelvba #msexcel](https://i.ytimg.com/vi/INk8RoBiA28/default.jpg)
![Excel VBA Macro: Delete All Sheets that Contain a Certain Text (String) Value](https://i.ytimg.com/vi/XbgpRws7VBQ/default.jpg)
![Excel VBA Macro: Resize Range (Table) Pasted As Image In Email Body](https://i.ytimg.com/vi/MEi1m9h9L58/default.jpg)
![Excel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each Row](https://i.ytimg.com/vi/PmdyyEFCJFU/default.jpg)
![Excel VBA Macro: Save File As Previous Work/Business Day (Excluding Holidays)](https://i.ytimg.com/vi/WYSahXeCkFU/default.jpg)
![Excel VBA Macro: Send Email with Hyperlink (that has Spaces in the File Name)](https://i.ytimg.com/vi/HjIaP9UvuE0/default.jpg)
![Excel VBA Macro: Right Align Image in Email Body (and Resize)](https://i.ytimg.com/vi/rSSaSCMTOxo/default.jpg)
![Excel VBA Macro: List Time Last Saved (For All Files In Folder)](https://i.ytimg.com/vi/7qnO37TsojE/default.jpg)
![Excel VBA Macro: Delete Rows If Any Cell in Those Rows (Across All Columns) Contains a Certain Value](https://i.ytimg.com/vi/H2jM1m0zNkk/default.jpg)
![Excel VBA Macro: Autofilter And Copy/Paste To Multiple Sheets (Dynamic Range)](https://i.ytimg.com/vi/unUgUlEBvu4/default.jpg)
![Excel VBA Macro: Resize Large Table Ranges After Pasting (As Image) In Email Body](https://i.ytimg.com/vi/rQPfwhurY1s/default.jpg)
![Excel VBA Macro: Export Selected Range as Image (Save Range as Picture)](https://i.ytimg.com/vi/vRNctWgrtxc/default.jpg)
![Excel VBA Macro: Send Email with Attachments from a List (Dynamic Range)](https://i.ytimg.com/vi/7imUc0YhfV0/default.jpg)
![Excel VBA Macro: Remove Special Characters (in List of Strings) & Post New Strings Next to Old Ones](https://i.ytimg.com/vi/po_1Cl3suAw/default.jpg)
![Excel VBA Macro: Capitalize First Letter of Every Word in a (Static/Dynamic) Range of Strings](https://i.ytimg.com/vi/I6IquFv6pN8/default.jpg)
![Excel VBA Macro: Find Sheet in Another (User Selected) Workbook and Copy Data Over](https://i.ytimg.com/vi/TBPPa_RPCHk/default.jpg)
![Excel VBA Macro: Create Word Document & Add Table (Static Range)](https://i.ytimg.com/vi/z9l5OySTpCQ/default.jpg)
![Excel VBA Macro: Add New Sheets To Beginning Or End of Workbook (With Names)](https://i.ytimg.com/vi/ejWJaiwZOAs/default.jpg)
![Excel VBA Macro: Save Selected Range as PDF (and Center on Page)](https://i.ytimg.com/vi/d-st754vi44/default.jpg)