Looking for some help with autofilling using VBA
I have a table and would like to add a drop-down list (using data validation) in column B until the last row using VBA.
I tried the VBA code below but unfortunately couldn't get it to work. Any insight or pointers will be super appreciated!
I have a table and would like to add a drop-down list (using data validation) in column B until the last row using VBA.
I tried the VBA code below but unfortunately couldn't get it to work. Any insight or pointers will be super appreciated!
A | B | |
1 | Sample 1 | |
2 | Sample 2 | |
3 | Sample 3 |
VBA Code:
Sub listCreator()
Dim last_row As Long
last_row = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="YES,NO"
Range("B1").AutoFill Destination:=Range("B1:B" & last_row)
End Sub