VB script/macro help - please !!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Forgive me for my waffle but I'm new to this and will try and explain what I
want.

I have a workbook where I have my own personal toolbar. On here I have
placed a macro button which the user will 'click' on to create a new
worksheet.
I want this worksheet to be pre formatted with certain text and formula in
it, and the newly created worksheet to be automaticaly renamed after that
particulay days date, ie 10 July.
Once the workbook has been saved, I want the user to be able to repeat this
process every other day, ie create a new worksheet , which is renamed after
that day and which is already pre formatted.

Is this possible - do I want too much ??
Can anybody offer some script for this??
many thanks in advance
 
Try something like this as a sample to work from.

Sub todaySheet()
Dim shtNew As Worksheet
Dim shtTest As Worksheet
Dim strNewName As String
Dim shtExist As Boolean
shtExist = False
strNewName = CStr(Day(Date)) & " " & CStr(Format$(Date, "mmmm"))
For Each shtTest In ActiveWorkbook.Worksheets
If shtTest.Name = strNewName Then
shtExist = True
End If
Next shtTest
If Not shtExist Then
Set shtNew = Worksheets.Add
With shtNew
..Name = strNewName
..Range("A1").Font.Bold = True
..Cells(1, 1).Value = "This is a new sheet"
..Range("A:A").AutoFormat
End With
End If
End Sub


Steve Yandl
 

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