Wednesday, December 10, 2025

How to open notepad with for loop and enter a to z characters in excel automatically

 Sub SendAlphabet_AtoZ()


Shell "Notepad.exe", vbNormalFocus

    Dim i As Integer

    Dim char_code As Integer

    Dim current_char As String

    Dim row_num As Integer

    

    

     Dim z As Integer


For z = 1 To 50

    row_num = 1

    ' Loop through ASCII codes for lowercase 'a' (97) to 'z' (122)

    For char_code = 50 To 122

        ' Convert the ASCII code to a character

        current_char = Chr(char_code)

        Application.Wait (Now + TimeValue("00:00:00"))

        ' Place the character in the active worksheet in column A

         SendKeys current_char

        

        ' Move to the next row

        

    Next char_code


Next z

  

End Sub

No comments:

Post a Comment