excel - Find function not returning value with number format -


i have code searches through each worksheet within active workbook , returns sheet name whenever value found. unfortunately case when range formatted "general". not return name of sheet if range formatted "number". instead set range nothing , exit loop. want keep number format intact.

    function findsheetname(srch string) string      dim ws worksheet     dim rng range     findsheetname = "cannot find gl code"      each ws in activeworkbook.worksheets         if ws.visible = xlsheetvisible             ws.range("b:b")                 set rng = .find(what:=srch, _                             after:=.cells(.cells.count), _                             lookin:=xlvalues, _                             lookat:=xlwhole, _                             searchorder:=xlbyrows, _                             searchdirection:=xlnext, _                             matchcase:=false)                 if not (rng nothing or _                        ws.name = "operating statement" or _                        ws.name = "data" or _                        ws.name = "report" or _                        ws.name = "other_income_financial")                             findsheetname = ws.name                            exit                 end if             end         end if     next ws  end function   sub findgl()  set srctab = sheets("data") srctab.activate  'dim shtname string dim glcode string  endrow = worksheetfunction.counta(range("b:b"))  'loop find invoice  = 4 endrow      glcode = range("b" & i).value      range("f" & i).value = findsheetname(glcode)  next  end sub 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -