ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   new worksheets based on list (https://www.excelbanter.com/excel-programming/306820-new-worksheets-based-list.html)

tanama

new worksheets based on list
 
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


---
Message posted from http://www.ExcelForum.com/


Dave Peterson[_3_]

new worksheets based on list
 
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




"tanama <" wrote:

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

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 01:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com