I want to make copying cells easy.

There is a list of names divided into 3 groups on Sheet1.
Group 1 : Name1 Name2 … Name9 Name10
Group 2 : Same as above
Group 3 : same as above

A leader is selected from each group, and the leader changes every month.

For example, for September
Group 1 : leader name7, members name1…6, 8…10
Group 2 : leader name4, members name1…3, 5…10
Group 3 : leader name8, Members name1…7, 9…10

Is there a function to display name7 in simple notation by simply typing 1_7 for the leader of group 1?
Or how do I enter the formula?

(LibreOffice 7.6)
[DeepL]

99279.ods (47.5 KB)

1 Like

Welcome!
Unfortunately, the short syntax of the form 1_7 is not provided for indexes in a matrix. You can use syntax like 1;7 in the INDEX() function, like =INDEX(ListOfGroups;1;7). Or in the OFFSET() function. But in this case, it is advisable to have a cell above and to the left of your group list so that the function can refer to this cell as the base one. For example, if the list of groups is located in the range B2:K4 as in the attached file, then a formula of the form

="leader "&OFFSET($A$1;GroupNumber;LeaderNumber)&", members "&SUBSTITUTE(TEXTJOIN(" ";1;OFFSET($A$1;GroupNumber;1;1;10));OFFSET($A$1;GroupNumber;LeaderNumber)&" ";"")

will do the work

As you can see, the formulas are too long, but you just wanted to shorten the entry. It seems to me that using a custom function is what you are looking for. Not very complicated code

Function getGroup(aList As Variant, nGroup As Long, nLeader As Long) As String 
Dim i As Long, sRes As String 
	For i = LBound(aList,2) To UBound(aList,2)
		If i <> nLeader Then sRes = sRes & aList(nGroup, i) & ", "
	Next i
	getGroup ="leader " & aList(nGroup, nLeader) &", members " & Left(sRes, Len(sRes)-2)
End Function

and formulas

=GETGROUP($B$2:$K$4;1;7)
=GETGROUP($B$2:$K$4;2;4)
=GETGROUP($B$2:$K$4;3;8)

will give you the desired result immediately
getGroupLeader.ods (18.1 KB)

1 Like

Nice to meet you. This was my first post.
It reflected exactly what I wanted to do,
I can create an annual list based on the sample code.
Thank you very much for showing a very clear sample code.

Since the dropdown list is set in B2:B4
please select.
Once the leader is determined, the members behind him will automatically change.

The member list is on Sheet2.

cellseasy.ods (11.7 KB)

1 Like

With OFFSET, it becomes a very long equation, and with my tiny brain, smoke is likely to come out of my head along the way.
I have shied away from macros but am thinking of learning BASIC or Python.
Thank you very much.

I learned MSX-BASIC a long time ago, but never started on macros because VBA and LibreOffice BASIC are completely different ways of writing.
SUMPRODUCT is new to me.
INDEX is useful.
Thanks for showing the sample data.

If you look closely at the function that I proposed, you can see only one discrepancy: VBA accepted as the first parameter a range of cells from which values should be extracted, while Star-Basic immediately accepts a two-dimensional array of values. Everything else - the loop, conditional execution, string concatenation, returning the result - is absolutely the same.

Anything related to groups, memberships, roles, relations, inventories, accounting should be stored in a database.
99279.odb (33.7 KB)