Rotating Cell Contents with Exceptions?

sclipary3

New Member
Joined
Apr 28, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I would like to use the formula described in the Excelisfun YouTube video
to rotate the content of cells.
=INDEX($A$2:$A$10,IF(ROWS(C$2:C2)>I$9,ROWS(C$2:C2)-I$9,I$5+ROWS(C$2:C2)-1))
My goal is to rotate a list of employees through office tasks. Being an Excel novice, I can follow the logic in the formula, but don't think I have the knowledge to further manipulate or expand on it. My question is, do we think it would be possible to build-in an exception for the event when the next person up in the rotation is not available? I don't want that person to be completely skipped and rotated back to the bottom, but rather have them retain the top spot (for when the are next available). In this case, the second person in line would take the assignment that day, and each of the cells from then second person down in the list would rotate. I completely understand this may take more than one formula to accomplish and I'm open to any/all suggestions for how this might be done.

Thank you in advance.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Using VBA

Book1 (version 1) (version 1).xlsb
ABC
1NameAvailableTask
2JasonFALSETask A
3TeresaTRUETask B
4EddyFALSETask C
5MikeTRUETask D
6AllisonTRUETask E
7BillTRUETask F
8ChrisTRUETask G
9AdamTRUETask H
10GinaTRUETask I
11BryanTRUETask J
Sheet8


VBA Code:
Sub ROTATE()
Application.ScreenUpdating = False
Dim r As Range:         Set r = Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row)
Dim AR() As Variant:    AR = r.Value2
Dim AL As Object:       Set AL = CreateObject("System.Collections.ArrayList")
Dim tmp As String

For i = 1 To UBound(AR)
    If AR(i, 2) Then AL.Add AR(i, 1): AR(i, 1) = vbNullString
Next i

tmp = AL(AL.Count - 1)
AL.removeat (AL.Count - 1)
AL.Insert 0, tmp

For j = 1 To UBound(AR)
    If AR(j, 1) = vbNullString Then AR(j, 1) = AL(0): AL.removeat (0)
Next j

r.Value2 = AR
Application.ScreenUpdating = True
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
Latest member
Motoracer88

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