How can we write code to insert names list automatically in excel sheet, what is the vba code for this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
kiran kumar85
This is how you can write vba code to insert names in excel sheet automatically with VBA code.
Vba Code to insert names list in Excel sheet:
Sub InsertNamesInList()
Dim selectedRow, i, diff As Integer
Dim selectedColumn As String
Dim names As Variant
diff = 0
names = Array(“Alice”, “Bob”, “Charlie”, “New Name”, “Text”, “Adam”, “Sam”, “Shiby”, “Dude”, “Alex”)
selectedColumnNumber = Selection.Column
selectedRow = Selection.Row
For i = 0 To UBound(names)
Cells(selectedRow + (i + diff), selectedColumnNumber).Value = names(i)
Next i
End Sub
Satish
Thanks for this code this has been very useful for me.
kiran kumar85
For how many years you have been using Excel VBA code?