arrays - Macro to read cells in one sheet and then search for match in another sheet and add date to column -


i'm trying write excel macro go down column of text , search each item in column in spreadsheet in same workbook. when value found should put todays date in specific column e.g. column h. have found code first part , piece of code second part. haven't got knowledge of coding put 2 , make work. 2 pieces of code shown below.

sub from_sheet_make_array()    dim myarray variant   dim cells range   dim cl          myarray = range("a1:a10").value        set cells = worksheets("sheet2").columns(1).cells        set cl = cells.cells(1)             if iserror(application.match(cl.value, myarray, false))       exit sub       else:             = + 1       'this shows each item in column in messagebox       'need pass value other code somehow             msgbox (cl.value)       end if 

set cl = cl.offset(1, 0) loop while not isempty(cl.value) end sub

sub searchlist()  dim c range activeworkbook.sheets("sheet1") ' search whatever in "" ' somehow need cl.value (myarray) in here     set c = .columns("a").find(what:="text", _                                lookin:=xlformulas, lookat:=xlpart, _                                searchorder:=xlbyrows, _                                searchdirection:=xlnext, matchcase:=true)              c.offset(0, 8).value = date end exit sub 

end sub

if can stitch them or point me in right direction of how go me out. way off new this. offered.

from understanding you're in process of checking if have entry today in worksheet , if do, put date-stamp in current worksheet. try this: (let me know if works!)

sub datestampiffound() dim cell range dim temp range each cell in sheets("worksheet_containing_search_criteria").usedrange.columns("specify_the_column").cells     'so dont search blanks , skipping header row     if cell <> "" , cell.row<>1         set temp = sheets("worksheet_where_you_want_the_find_to_happen").columns("specify_the_column").find(what:=cell.value, _                             lookin:=xlformulas, lookat:=xlpart, _                            searchorder:=xlbyrows, _                            searchdirection:=xlnext, matchcase:=true)         'if found         if not temp nothing             'if search_criteria in same sheet             cell.offset(0, number_of_columns_offset_from_cell) = date         end if     end if next 

end sub


Comments