473,396 Members | 1,804 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,396 software developers and data experts.

How to copy sheet in workbook to another copy of it?

I am trying to build a vb macro in excel 2007 that will allow me to copy the 4th sheet in my workbook and then create a new sheet from that copy with today's date as the label. I am still learning VB so I am not quite sure how to do this. Help please.
Jan 20 '11 #1
2 1727
Guido Geurs
767 Expert 512MB
This is the macro for Excel 2003.
Maybe You have to adapt it to 2007 !

Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2. Dim SHEETidx As Integer
  3.     For SHEETidx = 1 To Sheets.Count
  4.         If Sheets(SHEETidx).Name = CStr(Replace(Date, "/", "-")) Then
  5.             MsgBox "the sheet with this date exist!"
  6.             Exit Sub
  7.         End If
  8.     Next
  9.     Sheets("Sheet4").Select
  10.     Sheets("Sheet4").Copy After:=Sheets(Sheets.Count)
  11.     Sheets(Sheets.Count).Name = CStr(Replace(Date, "/", "-"))
  12. End Sub
Jan 20 '11 #2
Thank you very much for your help. This was perfect.
Jan 31 '11 #3

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

Similar topics

2
by: Alex | last post by:
Entering the following in the Python shell yields >>> help(dict.copy) Help on method_descriptor: copy(...) D.copy() -> a shallow copy of D >>>
0
by: russ2459 | last post by:
I am trying to write a vba code to have excel copy the active sheet, move to the end and rename based upon the date in a cell of the original worksheet. Any ideas?
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
0
by: Probleminfinity | last post by:
Hi, I have been trying to Copy a worksheet into another workbook and rename it using macro. But while running it Gives me an error: Run-time error '40036': Application-defined or object-defined...
0
by: ferlarroca | last post by:
Hi, I am trying to copy a range below another one...... I have defined two ranges as follow: Dim r1 As Range Dim r2 As Range Set r1 = Sheets("Old Index").Range("A9:A200, H9:H200, K9:K200")...
9
by: sitko | last post by:
Hi, I have an Order tracking spreadsheet that I need help with. I have a 2 worksheets "Open", and "Closed". I have entries on the "Open" sheet which may or may not be grouped together. I've...
0
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve...
2
by: Deven Oza | last post by:
Hi, Does anyone have an idea that how to copy column(s) from one excel sheet to another sheet using sql server. Thanks for your help in advance. -Deven
3
by: htmlnoob112233 | last post by:
How do you point to a style sheet in another directory using the below code i.e. the directory needed is ../style/style.css code <link rel="stylesheet" type="text/css" href="<?php echo...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.