LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 229
Default macro - modification

Hi All
I have received the following macro from Greg Wilson. I copies down a range
into respective month sheet and date column based on date (C2). I created
the month sheets manually.
What i need is the macro should check whether the month sheet is created or
not. If it is not, create month sheet and copy else copy the range.


Sub k()
Dim r As Range
Dim m As Integer, d As Integer
Dim msg As String, ttl As String
Dim sheetnames As Variant

sheetnames = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

With Sheets("Data")
With .Range("C2")
If Not IsDate(.Value) Then
msg = "Error: Date not entered in cell C2"
ttl = "Student Attendance"
MsgBox msg, vbCritical, ttl
Exit Sub
End If
m = Month(.Value)
d = Day(.Value)
End With
Set r = .Range(.Cells(3, 5), .Cells(3, 5).End(xlDown))
End With
With Sheets(sheetnames(m - 1)).Cells(3, d).Resize(r.Count)
..Value = r.Value
End With
Set r = Nothing
End Sub

With regards
Sreedhar
 
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 modification question Steve Excel Discussion (Misc queries) 1 September 7th 07 12:47 AM
Macro Modification carl Excel Worksheet Functions 0 May 4th 07 04:17 PM
Macro Modification Carl Excel Worksheet Functions 2 August 30th 06 01:53 PM
Macro modification Hirsch Excel Discussion (Misc queries) 3 May 27th 05 10:21 PM
Macro Modification Help Dmorri254 Excel Worksheet Functions 0 March 4th 05 03:51 PM


All times are GMT +1. The time now is 12:03 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"