Forum Discussion

Liosnia's avatar
Liosnia
Copper Contributor
Jun 05, 2022
Solved

Use VBA to autofill a range of row based on user input

Hello,   I need help for this problem I want to make a visual basic modul that able to auto fill a triangle range of row with the data alfabet from a-z bassed on user input in inputbox.  ...
  • HansVogelaar's avatar
    Jun 05, 2022

    Liosnia 

    For example:

    Sub CreateTriangle()
        Dim i As Long
        Dim j As Long
        Dim c As Long
        Dim n As Long
        n = Application.InputBox(Prompt:="How many rows do you want to fill?", Type:=1)
        If n < 1 Then
            Beep
            Exit Sub
        End If
        Application.ScreenUpdating = False
        c = 65
        For i = 1 To n
            For j = 1 To i
                Cells(i + 1, j).Value = Chr(c)
                c = c + 1
                If c > 90 Then c = 65
            Next j
        Next i
        Application.ScreenUpdating = True
    End Sub

Resources