new worksheets based on list

T

tanama

Hi Everyone,

I've been having a problem trying to do something I believed would be
easy. I have a list of dates and numbers. I want to have a script
that, by default, would match today's date with the dates in the list,
and for each matching date, create a new worksheet named the number.
If anyone can give me some assistance, I would appreciate it very
much.

Thanks,
Tanama
 
D

Dave Peterson

One way is to just loop through your list:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

For Each myCell In Worksheets("sheet1").Range("a1:a20").Cells
If myCell.Value2 = CLng(Date) Then
Set wks = Worksheets.Add
On Error Resume Next
wks.Name = myCell.Offset(0, 1).Text '.value???
If Err.Number <> 0 Then
MsgBox "Renamed failed for sheet: " & wks.Name
Err.Clear
End If
On Error GoTo 0
End If
Next myCell

End Sub
 
Top