472,357 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,357 software developers and data experts.

sheet list to return exact name without any trim

232 100+
Expand|Select|Wrap|Line Numbers
  1. Sub SheetNames()
  2.     Columns(1).Insert
  3.     For i = 1 To Sheets.Count
  4.         Cells(i, 1) = Sheets(i).Name
  5.     Next i
  6. End Sub
This function returns sheet names very well but i want exact name without any trim for example for sheet name 0085 it returns 85 but i need same name to be returned i used cstr function but that still returns the same 85
kindly help
access 2007
Thanx in advance
Jun 13 '12 #1
1 1307
MikeTheBike
639 Expert 512MB
Hi

I thing this may solve the proble
Expand|Select|Wrap|Line Numbers
  1. Sub SheetNames() 
  2.     Columns(1).Insert
  3.     For i = 1 To Sheets.Count
  4.         Cells(i, 1).NumberFormat = "@"
  5.         Cells(i, 1) = Sheets(i).Name
  6.     Next iEnd Sub 
In short, the string is returned to the spreadsheet but the sheet then assumes it is a number, so you need to change the format to the Cell, in this example it formats it as text.

Alternatively you could format the cell with 4 leading zeros ie
Expand|Select|Wrap|Line Numbers
  1. Columns(1).Insert
  2.     For i = 1 To Sheets.Count
  3.         Cells(i, 1).NumberFormat = "0000"
  4.         Cells(i, 1) = Sheets(i).Name
  5.     Next i
HTH


MTB
Jun 13 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Colin Steademan | last post by:
Is there a method of returning the name of the current URL, without any of the path details? I am currently using request.serverVariables("url"), but this returns the name of the page and its path. ...
12
by: Mike Brashars | last post by:
Hi all, I have been searching for a week and am unable to find and example to "Populate picklist from directory and return file name". I have a php script that reads a log file and plots a...
4
by: Bill Borg | last post by:
Hello, I've got a simple shared property, e.g. Public Class dbObject Private Const m_ID As String = "ID" Public Shared ReadOnly Property ID() As String Get Return m_ID End Get End Property
0
by: Joey | last post by:
Does anyone know ahat type of DNS entries need to be made to a DNS server to allow for clients to access a site by only the domain name, without the host name? For example: cnn.com instead...
8
by: Tom | last post by:
Is there a function to get a variable to return its name w/datatype of string? i.e.: $var would return "var"
2
by: anilkumarup | last post by:
Code-- objExcel = New Excel.Application Error/Exception-- I have included all the apis microsoft.office.interop.excel etc in bin but it is not able to make object of excel class.
5
by: wassimdaccache | last post by:
Hello guys, I am trying to search in a form name "employee_list" every unique field. The idea is to return the name of the field that had the focus I am trying to write this Dim y...
6
by: Andrus | last post by:
I need to create method which returns my application object type as string : TypeName(typeof( List<int>)) should return "List<int>" or "System.Collections.Generic.List<int>" ...
8
by: Force88 | last post by:
hello, I have an xml file and I want to check if the string input in a textbox exist in a node but I dont know what to do. - For example: <equal> <hdd>HardDiskType></hdd> ...
7
snehil
by: snehil | last post by:
Is there any way to return the name of the control I click on in a window form application using C#? Using this pointer only returns name of the form.
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.