new worksheets based on list

  • Thread starter Thread starter tanama
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top