VBA to Conditionally Reorder/Move Sheets Upon Workbook Open

default_name

Board Regular
Joined
May 16, 2018
Messages
170
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hey all,

I have a workbook with a tab named 'References'
Based on the current date, I would like the 'References' tab/worksheet to be assigned/moved as follows.

If today's date falls between:'References' Sheet Position in the Workbook
Jan13 - Jan263rd tab from left
Jan27 - Feb94th tab from left
Feb10 - Feb235th tab from left
Feb24 - Mar86th tab from left
....it continues for several more sheets in the workbook (27 to be exact).
I think I can get the rest of the sheet set up as long as the initial pattern is set for the others.

I imagine it would be something like this integrated into a conditional statement?
VBA Code:
Sheets("References").Move before:=Sheets(3)

Thanks in advance for your help!
 
Last edited:
That worked! Thank you so much for your patience!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Do you need a table? It looks like the change dates are each all a neat 14 days apart (after the first date). If that is the case, would this simple code do what you want without the need for any table or list?

VBA Code:
Sub Move_References()
  Application.ScreenUpdating = False
  With Sheets("References")
    .Move After:=Sheets(Sheets.Count)
    .Move After:=Sheets(Int((Date - DateSerial(Year(Date), 1, 1) + 2) / 14) + 1)
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,067
Members
449,090
Latest member
fragment

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