473,385 Members | 1,587 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.

Willdcards in Sheet Name

25
Hi,

I am using VB 6.3 for excel and i have the foillowing code:

Expand|Select|Wrap|Line Numbers
  1. Sheets.Add
  2. Sheets("Sheet1").Select
  3. Sheets("Sheet1").Name = "Results"
The problem is that when I re-run the program the sheet that gets created is incremented by 1, so renaming it doesn't work.

I tried using a wildcard for the numerical charactor (below), but it didn't work.

Expand|Select|Wrap|Line Numbers
  1. Sheets.Add
  2. Sheets("Sheet*").Select
  3. Sheets("Sheet*").Name = "Results"
Does anyone have an idea for a solution that would make this work?
Aug 18 '08 #1
2 1197
The sheet that is added becomes the active sheet.
So just rename the active sheet...

Sheets.Add Count:=1
ActiveSheet.Name = "Results"

Note that each sheet in an Excel workbook must have a unique name - you cannot have two sheets named Results.
Aug 18 '08 #2
kadghar
1,295 Expert 1GB
Sheets indexes can be Strings or Integers

if your sheets are
Sheet1, Sheet2, Sheet3, Sheet4, Sheet5

you can check them inside a loop using an integer with:

Expand|Select|Wrap|Line Numbers
  1. dim i as integer
  2. for i = 1 to 5
  3.     sheets(i).name = "MySheet" & i
  4. next
or using a string:

Expand|Select|Wrap|Line Numbers
  1. dim i as integer
  2. dim Str1 as string
  3. for i = 1 to 5
  4.     Str1 = "Sheet" & i
  5.     sheets(Str1).name = "MySheet" & i
  6. next
well

HTH
Aug 18 '08 #3

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

Similar topics

5
by: Rajiv | last post by:
HI ALL, actually , i m working in a company having large number of employee , i have two userid and password . on id is from admin group(id given to me by technology manager) of the server and...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
3
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
18
by: Frank M. Walter | last post by:
Hello, I have made an small AddIn with udf for excel 2003. I use vs2003. The point of view is the function __T() I call it in excel sheet writing =__T() I am not able to set a value to a...
0
by: isis5 | last post by:
i am using c# to parse some excel files to oracle.these files are created by an automated 3rd party process and we have no control over the naming convention and the version is excel 4.0 and the...
1
by: tanilov | last post by:
Hi all, I need to read data from an excel file and populate a dataset. After some search I found following code: connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +...
2
by: glibo | last post by:
I am trying to change the tab name when i open a excell spread sheet on the run time in c#. I changed it in the code: Response.AddHeader("content-disposition","filename=" + sFileName + ".xls");...
2
by: kunalgujar | last post by:
I am using ASP to open a excel file. I've noticed that Internet Explorer adds a number in square brackets to files downloaded from the internet and opened directly (i.e. by clicking 'Open' and not...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.