Skip to content

Instantly share code, notes, and snippets.

View Hunu's full-sized avatar
🏠
Working from home

Hunu Hunu

🏠
Working from home
  • Freelancer
View GitHub Profile
@Hunu
Hunu / find_str_in_a_column.vb
Last active May 20, 2020 03:36
This is a User Defined Formula in EXCEL, which will looking for the first cell that contains(NOT the 'match') the str_to_find in a column, and return it's number of row.
Function find_str_in_a_column(str_to_find As String, col_no As Integer, wws As Worksheet) As Integer
'In {wws}(working worksheet), column of {col_no},RETURN the row number of the first cell which contains {str_to_find}
'Or return -1 if not found
Dim arr()
Dim re As Integer
Dim i As Integer
With wws
re = .Cells(65536, col_no).End(xlUp).Row
arr = .Range(.Cells(1, col_no), .Cells(re, col_no)).Value2