Okay, so I recently got into VBA programming and I have been trying to write some code to do the following :
- Cycle through a column containing True or False Statements (column "K" in my case)
- If True then gather the corresponding name (column "C") and create a sheet named accordingly
And that's all
So here is the code I wrote :
Sub Generate_Attribute_Table()
Dim LastRow As Long
Dim i As Integer
Dim Nom As String
LastRow = Range("A1").End(xlDown).Row
For i = 2 To LastRow
If (Cells(i, "K").Value) Then
Nom = Worksheets(1).Cells(i, "C").Value
ActiveWorkbook.Sheets.Add(After:=Worksheets(Sheets.Count)).Name = Nom
Else
Cells(i, "K").Select
End If
Next i
End Sub
And it seems to work perfectly fine but it stops after generating the first sheet even if there are other True in the column.
The else case is there for debug purposes as I wanted to see what was happening and it confirms that whenever the if statement is verified, the loop stops.
I tried doing the same thing using a "Do Until" loop but it does the same.
What am I missing here ? I couldn't find any answers online so any help would be really nice.
Thanks in advance.