I have this code and it works to find the first row of data in colB where it excludes the header row.
first_data_row = ws.Cells.Find(What:="*", After:=[B1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row
However, when i try to make the code more flexible by makeing B1 a variable .....i get a type mismatch........see below
Dim study_col As Integer
fl_name = ThisWorkbook.Name
Set ws = Workbooks(fl_name).Worksheets("Sheet1")
Set ws3 = Workbooks(fl_name).Worksheets("Sheet3")
study_col = 2
'first_data_row = ws.Cells.Find(What:="*", After:=[B1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row
first_data_row = ws.Cells.Find(What:="*", After:=[alphacol(study_col) & "1"], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row
MsgBox (first_data_row)
I am enclosing an excel file as this usually makes things easier.
Bookmarks