473,748 Members | 7,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple VBA programming in Excel

I am trying to write a simple VBA program for a spreadsheet. However I
am stuck. I am learning this as I go along so that is the big problem
no doubt. I need to copy a sheet and rename. Simple eh? I copy it no
problem but cannot figure how to change the copyed name (now
firstname(2) for instance) to a new name. A cut out of the utility is
below:

Private Sub copysht()
sname = "dog"
Sheets("Templat e").Copy after:=Workshee ts(Worksheets.C ount) '.name
= "sname" 'copy at the end
Sheets("Templat e(2)").name = "sname"
'ActiveWorkbook .Sheets("Templa te(2)").name = "sname" 'give sheet a new
name but it blows up on Template(2)!
End Sub
Mar 4 '08 #1
2 1379
md
You would have a better chance of getting an answer if you post to a
newsgroup on VBA or Excel. This is a .Net programming group.

<wa***@btintern et.comwrote in message
news:a8******** *************** ***********@u10 g2000prn.google groups.com...
>I am trying to write a simple VBA program for a spreadsheet. However I
am stuck. I am learning this as I go along so that is the big problem
no doubt. I need to copy a sheet and rename. Simple eh? I copy it no
problem but cannot figure how to change the copyed name (now
firstname(2) for instance) to a new name. A cut out of the utility is
below:

Private Sub copysht()
sname = "dog"
Sheets("Templat e").Copy after:=Workshee ts(Worksheets.C ount) '.name
= "sname" 'copy at the end
Sheets("Templat e(2)").name = "sname"
'ActiveWorkbook .Sheets("Templa te(2)").name = "sname" 'give sheet a new
name but it blows up on Template(2)!
End Sub

Mar 4 '08 #2
On Mar 4, 7:03*pm, "md" <some...@micros oft.comwrote:
You would have a better chance of getting an answer if you post to a
newsgroup on VBA or Excel. This is a .Net programming group.

<wa...@btintern et.comwrote in message

news:a8******** *************** ***********@u10 g2000prn.google groups.com...
I am trying to write a simple VBA program for a spreadsheet. However I
am stuck. I am learning this as I go along so that is the big problem
no doubt. I need to copy a sheet and rename. Simple eh? I copy it no
problem but cannot figure how to change the copyed name (now
firstname(2) for instance) to a new name. A cut out of the utility is
below:
Private Sub copysht()
* *sname = "dog"
* *Sheets("Templa te").Copy after:=Workshee ts(Worksheets.C ount) '.name
= "sname" 'copy at the end
* *Sheets("Templa te(2)").name = "sname"
'ActiveWorkbook .Sheets("Templa te(2)").name = "sname" 'give sheet a new
name but it blows up on Template(2)!
End Sub- Hide quoted text -

- Show quoted text -
Thanks for the pointing that I hopefully I found one.

Wayne
Mar 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1169
by: Weimin Zhang | last post by:
Hi, following is the VBA code generated by Macro in Excel XP (2002). What I would like to do is to incorporate the same thing into C#, but I don't know how to pass the Array () to C# in the Workbooks.OpenText() method. Can anyone please help me on how to pass these parameters for this method in C#? Thanks a lot! Sub WMTest() ' ' WMTest Macro
0
1465
by: Aaron Prohaska | last post by:
I need to write a program in .net csharp to write to an open Excel 2000 instance and need of some help. Is it possible to open an excel file then get a reference to the running process using csharp, then write to the worksheet. What I don't want to have to do is specify the filename of the excel file that I need to write to. I've seen this done using C++, but have not been able to find any examples of doing this with csharp. Regards,
2
5454
by: Eric Johannsen | last post by:
Hi, Is there any open source / demo code that shows how to create a simple Excel 97 or later file without resorting to Interop? My application currently creates a simple CSV file, but I would like it to be able to create an XLS file with a single workbook, and add simple attributes to the cells (color, font, value). Searched GotDotNet and Source Forge, but didn't find anything yet.
4
1110
by: ibeetb | last post by:
My head is exploding with the 500 different ways shown on Microsoft's site to program Excel (Office) Can anyone offer the best solution to the following: I want to program a couple of Excel reports for both Mac Users and PC users and have them access from a web site. These users not only have different platforms (Mac and PC) but many have different versions of Excel (XP, 2002, 2003, 2000). What does Microsoft have out there that would be...
1
1803
by: MattNZ | last post by:
I am working in access on a program which requires me to multiply all the values in a field by each other. This is easy to replicate in excel, but I can't figure out how to do this in access. Here is how I would do it in excel to show u what I mean using columns A and B, the equation is simply B2=A2, then B3=B2*A3, B4=B3*A4, and copying this sequence down the column. It's really simple, but what do i do in Access to achieve the same result? ...
0
961
by: NeedHelp666 | last post by:
Hi there, the following compiles fine, but when I run it, It does nothing. Could someone please help me? BTW, its supposed to show the menu, take the input, and spit out the resulting message. All help is appreciated, hope it doesn't take up too much time out of ur cs or wow playing. Thanx. #include<iostream> using namespace std; void intsructions(); int read_choice(); void out_of_range(); int menu(); void output(int); int main()
6
4959
by: Duncan Smith | last post by:
Hello, I am currently implementing (mainly in Python) 'models' that come to me as Excel spreadsheets, with little additional information. I am expected to use these models in a web application. Some contain many worksheets and various macros. What I'd like to do is extract the data and business logic so that I can figure out exactly what these models actually do and code it up. An obvious (I think) idea is to generate an acyclic...
2
1918
by: bg_ie | last post by:
Hi, I wish to develop some features for an excel document. The version of excel is 2002 SP3. I'm using Visual Studio 2005. Is it possible for me to program in C# instead of VBA? Thanks, Barry.
6
1892
by: mwhit74 | last post by:
here is the code: // CS 200 Lab 11 Problem 3 - phone.cpp // Test program for the keyToTones function. #include <iostream> using namespace::std; // Definition of the PhoneTones struct
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.