Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Problem


Hi. Sorry if this question has been posted before, but I can't seem to
find any solution for this. I'm trying to create a macro (I think) that
would allow me to copy a whole worksheet and paste it to another new
worksheet in Excel. The problem is that everyday, there are new data
added to the worksheet with the current date. Hence I want to copy the
data from the current date and paste it to a new worksheet. Also there
are 49 databases with the new data each date and it needs to be copied
all into one worksheet. Any help would be appreciated.


--
alucard
------------------------------------------------------------------------
alucard's Profile: http://www.excelforum.com/member.php...o&userid=27764
View this thread: http://www.excelforum.com/showthread...hreadid=472702

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro Problem

Hi alucard,

Try this code below:

Sub NewSheet()
Dim shtName As String
Dim wSht As Worksheet

'Point the Cells(1,1).Value to dates you want to archive or type on Cell A1
"=Now()" for sample
'then test macro
'For combining all the sheets "UsedRange" and put it on a particular
sheetname.

shtName = Format(Cells(1, 1).Value, "ddmmmyy")
For Each wSht In Worksheets
If wSht.Name = shtName Then
MsgBox "Sorry! This sheet already exists."
Exit Sub
End If
Next wSht
Sheets.Add.Name = shtName
Sheets(shtName).Move Befo=Sheets(Sheets.Count)
Sheets("Sheet1").UsedRange.Copy Sheets(shtName).Range("A1")
Sheets("Sheet1").UsedRange.Copy

Sheets(shtName).Select
ActiveSheet.UsedRange.Select
Selection.PasteSpecial Paste:=xlPasteValues
Cells.Select
Cells.EntireColumn.AutoFit

Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Range("A1").Select
End Sub


For combining all the sheets refer to weblink below.

http://www.ozgrid.com/forum/showthread.php?t=17158

"alucard" wrote:


Hi. Sorry if this question has been posted before, but I can't seem to
find any solution for this. I'm trying to create a macro (I think) that
would allow me to copy a whole worksheet and paste it to another new
worksheet in Excel. The problem is that everyday, there are new data
added to the worksheet with the current date. Hence I want to copy the
data from the current date and paste it to a new worksheet. Also there
are 49 databases with the new data each date and it needs to be copied
all into one worksheet. Any help would be appreciated.


--
alucard
------------------------------------------------------------------------
alucard's Profile: http://www.excelforum.com/member.php...o&userid=27764
View this thread: http://www.excelforum.com/showthread...hreadid=472702


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Problem using Day() in a macro Marie Excel Worksheet Functions 2 December 14th 07 06:01 PM
Problem with Macro ChuckW Excel Discussion (Misc queries) 0 March 28th 07 01:16 AM
macro problem Kevin Excel Discussion (Misc queries) 1 December 14th 04 10:47 PM


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"