LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Copying sheet and generating name of new sheet

I need to create macro that would make a copy of sheet named "blank" and will
name this (copied) sheet like value specified in cell - M8 !
And before creating name for new sheet this macro should also put today's
date (Now()) in cell A1 of new sheet
I want to run this macro by keypress. For example Ctrl + F12

Now i will explain why i need this.

Cell M8 will contain formula:
=IF(ISBLANK(A1);"blank";IF(OR(WEEKDAY(A1;2)=7;WEEK DAY(A1;2)=6);"|";"")&TEXT(DAY(A1);"d")&IF(OR(WEEKD AY(A1;2)=7;WEEKDAY(A1;2)=6);"|";""))

This fomula read's value from cell A1 (as mentioned above cell A1 will
contain today's date)
If A1 will contain value "15.08.2005" (dd-mm-yyyy) then value of M8 will be
15
If A1 will contain value "14.08.2005" then value of M8 will be |14|

In a word if A1 will contain weekend day then value in M8 will be number
representing the day enclosed with lines, else it will put number
representing the day without any lines

Point of all this is that i need to create new tab for each day. And each
sheet must contain today's date in A1 and sheet's name should represent that
days number and if it's a weekend day than nummber will be easily identified
by enclosing lines.
And i want to do all this by keypress becouse i have to repeat this every day.

So far i have code that would read value in cell M8

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sNAMECELL As String = "M8"
Const sERROR As String = "Invalid worksheet name in cell "
Dim sSheetName As String

With Target
If Not Intersect(.Cells, Range(sNAMECELL)) Is Nothing Then
sSheetName = Range(sNAMECELL).Value
If Not sSheetName = "" Then
On Error Resume Next
Me.Name = sSheetName
On Error GoTo 0
If Not sSheetName = Me.Name Then _
MsgBox sERROR & sNAMECELL
End If
End If
End With
End Sub

But that's far from what i need, cuz this is only renaming tab name
depending from value in cell M8 and works only if i open cell M8 for editing
and hit enter

Any ideas how do i acomplish this task ?
It would be even more effective if i could identify weekend days by having
different tab color instead of enclosing lines - for example red color. Any
ideas on this are also welcome :)

 
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
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. Alex Zuniga Excel Worksheet Functions 1 November 25th 09 11:54 PM
Copying the repeated data of the previous sheet to the next sheet Sasikiran Excel Discussion (Misc queries) 1 September 25th 07 03:18 PM
Dynamic column chart - copying from Sheet to Sheet. Marko Pinteric Excel Discussion (Misc queries) 1 April 10th 06 12:57 PM
Dynamic column chart - copying from Sheet to Sheet. Marko Pinteric Charts and Charting in Excel 1 April 10th 06 12:57 PM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM


All times are GMT +1. The time now is 03:22 AM.

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

About Us

"It's about Microsoft Excel"