Using a date to move a Worksheet

S

Steved

Hello form Steved

I have an excel file with 2 worksheets

Sheet1 is Named "Normal" Normal timetable.
Sheet2 is Named "School" School Holiday timetable.

Has anybody being able to apply a date to move worksheets

Whats my objective?

The both sheets are bus timetables

What is required is that on 05-Jul-09 Sheet1 and sheet2 swap places
Then on 18-Jul-09 Swap back.

I Thankyou.
 
J

JLGWhiz

You will need to change the date formats to satisfy your system
requirements, but it compiled OK. You need to test it, I did not. Put in
the ThisWorkbook code module.

Private Sub Workbooks_Open()
If DateValue(Date) >= DateValue("7/5/09") Then
Sheets("Normal").Move After:=Sheets("School")
ElseIf DateValue(Date) >= DateValue("7/18/09") Then
Sheets("School").Move After:=Sheets("Normal")
End If
End Sub
 
S

Steved

Hello JLGWhiz

I'll shall test it and let you know how I got on.

Steved

ps Thankyou.
 
J

JLGWhiz

Hi Steved, You should switch the dates in the If statement so that the later
date is tested first. Otherwise, the earlier date will test true each time
and the sheets will not change on the 18th.
 

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

Top