I am trying to insert a list of selected checkboxes into a spreadsheet, within this use case, a user can choose up to 15 items. This will be inserted into a certain cell which I have defined below.
I have a checkbox with the following names/values:
Name Value
========== =====
chk_week1 1
chk_week2 2
... ...
... ...
chk_week15 15
For example if the user selects chk_week1, chk_week2, chk_week4 and chk_week5, then it should be inserted into the cell as 1,2,4,5.
I’ve included an image how it looks like to better demonstrate it:

Each checkbox has the name and value listed in the table above. Here is the code I am using so far:
Private Sub btnSubmit_Click()
Dim ws As Worksheet
Dim rng1 As Range
Set ws = Worksheets("main")
' Copy the data to the database
' Get last empty cell in column A
Set rng1 = ws.Cells(Rows.Count, "a").End(xlUp)
' Having difficulty adding the code here
' rng1.Offset(1, 7) = weeks
End Sub
Thanks in advance.
This function would return the string you’re wanting to put in the cell.
Or for the non-looping method, check Francis Dean’s solution.