Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel sheet bootom half sheet goes behind top part of sheet rob Excel Worksheet Functions 2 January 17th 09 01:28 AM
Duplicate sheet, autonumber sheet, record data on another sheet des-sa[_2_] Excel Worksheet Functions 0 May 8th 08 06:56 PM
"='sheet 1'!D4" auto fill sheet to sheet ='sheet 2'!D4 mistewalker Excel Worksheet Functions 5 January 6th 08 11:36 PM
How do I select price from sheet.b where sheet.a part no = sheet.b Sonny Excel Worksheet Functions 4 April 4th 06 05:08 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"