VBA - Date format problem

lionelnz

Well-known Member
Joined
Apr 6, 2006
Messages
571
I have 2 macros that use the same code to rename a sheet and a new workbook using a date format string but it is now throwing a wobbly after working for nearly 18 months. Error message comes up that it can't compile as it cannot find project or library. I checked the VBA library and the Format.

Here is my full code for copying and renaming a worksheet based on a date in cell C19.

Code:
Sub CopySheetAs()
'This macro developed for timesheet
Dim shtname, Dt, Dt2, shtname2 As String

Dim a As Worksheet
Set a = ActiveSheet

Dim sCt As Integer

sCt = ActiveWorkbook.Sheets.Count


ActiveSheet.Copy Before:=Sheets(1)
'Adds a week to start of week date
ActiveSheet.Range("C19").Value = Range("C19").Value + 7

'Creates date format for new sheet name
[B][COLOR=#0000ff]Dt = Format(Range("C19").Value + 6, "DDMMYYYY")[/COLOR][/B] :(:(:(
shtname = "WE " & Dt
ActiveSheet.Name = shtname
Rows("19:36").Select
Range("K20").Activate
Selection.EntireRow.Hidden = False



'Creates week before date to be able to _
'move current activeSht to beginning
Dt2 = Format(Range("C25").Value - 7, "DDMMYYYY")
shtname2 = "WE " & Dt2

'a.Move after:=Sheets(shtname2)

End Sub

I have have tried repairing Office 2003, I have uninstalled & reinstalled offce 2003, I went back to an earlier restore point on XP prof SP3 with regular`updates.

I have checked the object browser for the the term "Format" and it is there.

I have tried deleting the line & rewriting it etc. still no joy!!!!!

Any suggestions?

TIA

Still no joy.
 
Last edited:
In the Visual Basic Editor select your workbook in the Project window and choose Tools|References. Look for any references marked MISSING and uncheck them.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top