Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I get the sheet name?
Hello,
I am importing specific information from CSV files and I want to get the sheet name for each file that I open so I can use it as a heading in the workbook that I am compiling the information in. How do I do this? Thanks, Jeff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I get the sheet name?
You using workbooks.open to open the .csv file?
If yes, you can get the name with something like: Option Explicit Sub testme01() Dim wksName As String Workbooks.Open Filename:="C:\My Documents\excel\book1.csv" wksName = ActiveSheet.Name msgbox wksName End Sub But you may just want to use a variable to represent that worksheet. Then you can do things like: wks.range("a1").value = "xxxx" instead of worksheets(wksName).range("a1").value = "xxxx" (and you wouldn't have to worry about qualifying the worksheets, either. That'll come along with the wks variable: msgbox wks.parent.name Sub testme02() Dim wks As Worksheet Workbooks.Open Filename:="C:\My Documents\excel\book1.csv" Set wks = ActiveSheet MsgBox wks.Name End Sub Jeff Armstrong wrote: Hello, I am importing specific information from CSV files and I want to get the sheet name for each file that I open so I can use it as a heading in the workbook that I am compiling the information in. How do I do this? Thanks, Jeff -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel sheet bootom half sheet goes behind top part of sheet | Excel Worksheet Functions | |||
Duplicate sheet, autonumber sheet, record data on another sheet | Excel Worksheet Functions | |||
"='sheet 1'!D4" auto fill sheet to sheet ='sheet 2'!D4 | Excel Worksheet Functions | |||
How do I select price from sheet.b where sheet.a part no = sheet.b | Excel Worksheet Functions | |||
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. | Excel Discussion (Misc queries) |