473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1351
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.