Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Anthony
 
Posts: n/a
Default VB script help - please!!

Linked to my previous question.........
I have this code below which once run creates a new worksheet (which is a
copy of my 'Log Master') - 2 problems.....
1 the script creates a copy of the Log Master sheet and renames it Log
Master1, Log Master2 etc and also crteats a blank sheet ie 'sheet1' , 'sheet2'
2 I want the newly created sheet to be renamed with todays date

my code
Sub Create_log()
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
Sheets("Log master").Visible = True
Sheets("Log Master").Copy After:=ActiveSheet
'ActiveSheet.Name =
Sheets("Log Master").Visible = False
End If
End Sub

Many thanks for your help - and go easy - I'm new to this


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I think you have another response at your previous thread that will help.

(Not mine)

Anthony wrote:

Linked to my previous question.........
I have this code below which once run creates a new worksheet (which is a
copy of my 'Log Master') - 2 problems.....
1 the script creates a copy of the Log Master sheet and renames it Log
Master1, Log Master2 etc and also crteats a blank sheet ie 'sheet1' , 'sheet2'
2 I want the newly created sheet to be renamed with todays date

my code
Sub Create_log()
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
Sheets("Log master").Visible = True
Sheets("Log Master").Copy After:=ActiveSheet
'ActiveSheet.Name =
Sheets("Log Master").Visible = False
End If
End Sub

Many thanks for your help - and go easy - I'm new to this


--

Dave Peterson
Reply
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
OsCommerce - Easy Populate Script - CSV/TXT Conversion Problem. PriceTrim Excel Discussion (Misc queries) 3 July 5th 05 06:27 PM
error in script from internet explorer fred6529 Excel Discussion (Misc queries) 0 June 11th 05 09:43 PM
VBA script help..Please !!!! Anthony Excel Discussion (Misc queries) 6 June 6th 05 02:40 PM
Using a VB Script for barcodes - new to this Jon Excel Discussion (Misc queries) 2 May 13th 05 03:42 PM
Macro script error - pls help !! Anthony Excel Discussion (Misc queries) 3 February 28th 05 02:49 PM


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