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

Hello
I put htis in worksheet functions also but I think it
should have been here. sorry

I hope some one can help me with this.
I have a work book with 52 sheets in it. each sheet
represents a week of the year with the tab being labeled
as the last day of the week ( 1-1-2005 )ect. which is
saturday. cell a10 on all the sheets is saturday I would
like a macro that would put the dates on all 52 sheets so
that a10 matches each sheet tab going backwards to a4
which would be the sunday before. ( desending )
this is the macro that I am trying to make work but it has
an error I can't figure out.
Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
If CDate(wks.Name) 0 Then
wks.Range("A10").Value = CDate(wks.Name)
For i = 6 To 1 Step 1
wks.Range("A10").Offset(i, 0).Value = CDate
(wks.Name) + i
Next
End If
Next wks
End Sub

Thanks in advance
Steve

..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default need a macro

Where's the error?

Not entirely certain I've got your logic correct either, but here goes...

Sub test()
Dim wks As Worksheet, i As Long

For Each wks In Worksheets
If IsDate(wks.Name) Then
For i = 0 To 6
wks.Range("A10").Offset(-i, 0).Value = CDate(wks.Name) + i
Next
End If
Next
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"steve" wrote in message
...
Hello
I put htis in worksheet functions also but I think it
should have been here. sorry

I hope some one can help me with this.
I have a work book with 52 sheets in it. each sheet
represents a week of the year with the tab being labeled
as the last day of the week ( 1-1-2005 )ect. which is
saturday. cell a10 on all the sheets is saturday I would
like a macro that would put the dates on all 52 sheets so
that a10 matches each sheet tab going backwards to a4
which would be the sunday before. ( desending )
this is the macro that I am trying to make work but it has
an error I can't figure out.
Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
If CDate(wks.Name) 0 Then
wks.Range("A10").Value = CDate(wks.Name)
For i = 6 To 1 Step 1
wks.Range("A10").Offset(i, 0).Value = CDate
(wks.Name) + i
Next
End If
Next wks
End Sub

Thanks in advance
Steve

.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default need a macro

See an answer in worksheet.functions.

In general, most of the regulars read both worksheet.functions and
..programming (along with .misc), so if you've posted in one place, it's
usually better to not repost in a second group - it just fragments your
answers and potentially wastes time of those answering a question that
has already been answered.

In article ,
"steve" wrote:

I put htis in worksheet functions also but I think it
should have been here. sorry

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default need a macro

Thanks again, hope you all have a good life
steve
-----Original Message-----
Hello
I put htis in worksheet functions also but I think it
should have been here. sorry

I hope some one can help me with this.
I have a work book with 52 sheets in it. each sheet
represents a week of the year with the tab being labeled
as the last day of the week ( 1-1-2005 )ect. which is
saturday. cell a10 on all the sheets is saturday I would
like a macro that would put the dates on all 52 sheets

so
that a10 matches each sheet tab going backwards to a4
which would be the sunday before. ( desending )
this is the macro that I am trying to make work but it

has
an error I can't figure out.
Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
If CDate(wks.Name) 0 Then
wks.Range("A10").Value = CDate(wks.Name)
For i = 6 To 1 Step 1
wks.Range("A10").Offset(i, 0).Value =

CDate
(wks.Name) + i
Next
End If
Next wks
End Sub

Thanks in advance
Steve

..


.

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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:44 PM.

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"