' Function to get the next alphabetical suffix (e.g., "", "A", "B", "C", ..., "Z", "AA", "AB", ...) Function GetNextSuffix(ByVal currentSuffix As String) As String If currentSuffix = "" Then GetNextSuffix = "A" ' Start with "A" Else ' Increment the last character of the suffix Dim lastChar As String lastChar = Right(currentSuffix, 1)
If lastChar = "Z" Then
' If it's "Z", change it to "AA", "AB", etc.
GetNextSuffix = Left(currentSuffix, Len(currentSuffix) - 1) & Chr(Asc(lastChar) + 1)
Else
' Otherwise, just increment the last character
GetNextSuffix = Left(currentSuffix, Len(currentSuffix) - 1) & Chr(Asc(lastChar) + 1)
End If
End If
End Function
I am getting error in this code.