![]() |
How to create a function to alternate names in a cell from a list?
Im creating a schedule and want to have a button that alternates names from a
list for the selected cell. |
How to create a function to alternate names in a cell from a list?
Here the list of name is in H1 thru H4:
Sub NextName() Dim r1 As Range, r2 As Range Set r1 = ActiveCell Set r2 = Range("H1:H4") If r1.Value = "" Then r1.Value = r2(1).Value Exit Sub End If v = r1.Value For Each rr In r2 If rr.Value = v Then Set r3 = rr.Offset(1, 0) If Intersect(r3, r2) Is Nothing Then Set r3 = r2(1) End If r1.Value = r3.Value End If Next End Sub Change the list to suit your needs. Assign a button (or any piece of clipart) to the macro. -- Gary''s Student - gsnu200841 "Elias" wrote: Im creating a schedule and want to have a button that alternates names from a list for the selected cell. |
All times are GMT +1. The time now is 06:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com