I have the following line of VBA code which is intended to find a column by header name and get the entire column as a range:
Set w1 = wbk.Sheets("Sheet1")
Set parentRange = w1.Rows(1).Find("portfolioName").Offset(1).Resize(num_rows - 1, 1)
It works perfectly fine in one workbook, however when I try it in a new workbook I get the following error:
<Application-defined or object-defined error>
I'm new to VBA so I'm not sure whether or not displaying code context or giving more details, is there something simple I could be neglecting to notice?
num_rows:
num_rows = w1.Cells(Rows.Count, 1).End(xlUp).row