Hi there, this is my first time posting. I'm a newbie to VBA and I'm trying to write a macro to name ranges - dynamically because the number of rows in my data will be different each week. I think I've figured out how to do it when all the cells are populated, but I've no idea what to do when there are blanks in the column. My code to name the ranges is below and I've posted an abbreviated version of my file. Any help would be greatly appreciated! Thanks in advance.
Sub nameRanges()
Dim Rng1 As Excel.Range
'set column A & B as the ranges to be named
With ActiveSheet
Set Rng1 = .Range("A2", .Range("A2").End(xlDown))
ActiveWorkbook.Names.Add Name:="Employees", RefersTo:=Rng1
Set Rng1 = .Range("C2", .Range("C2").End(xlDown))
ActiveWorkbook.Names.Add Name:="Area", RefersTo:=Rng1
End With
End Sub
Sub nameRanges()
Dim Rng1 As Excel.Range
'set column A & B as the ranges to be named
With ActiveSheet
Set Rng1 = .Range("A2", .Range("A2").End(xlDown))
ActiveWorkbook.Names.Add Name:="Employees", RefersTo:=Rng1
Set Rng1 = .Range("C2", .Range("C2").End(xlDown))
ActiveWorkbook.Names.Add Name:="Area", RefersTo:=Rng1
End With
End Sub