Excel 2003 VBA - Locate Date & Move Relevant data -
i need automate process that's not one-off event, ~500 facilities, each 100+ assets scheduled different dates throughout year completion. have workbook set main/source sheet 12 month sheets (jan, feb, march, ... dec). need sort of code allow me search particular date , send other same-row corresponding data appropriate sheet.
for example have asset due maintenance in june, 6/17/11. need excel search using month only, , moving asset it's name, description, cost, etc june tab. ive managed locate assets searching "6/" cannot find assets date of 6/17/11. copies needed data , attempts move proper sheet, when makes attempt microsoft visual basic error code 400 pops up. ideas? appreciated.
see if helps ...
private sub findcells() '' step 1, find rows containing date (june 2011 dates hardcoded in example) dim collectionofrowranges new collection dim ws worksheet dim rgcell range each ws in thisworkbook.worksheets each rgcell in ws.usedrange.cells if isdate(rgcell.text) if month(cdate(rgcell.value)) = 6 , year(cdate(rgcell.value)) = 2011 '' debugging ... watch , make sure stops @ right places ws.activate rgcell.select stop '' end of debug code call collectionofrowranges.add(rgcell.entirerow) end if end if next rgcell next ws '' step 2, copy rows new wb set ws = workbooks.add.sheets(1) ws.name = "june 2011 rows" dim rgrow range set rgcell = ws.cells(1, 1) each rgrow in collectionofrowranges call rgrow.copy call rgcell.entirerow.pastespecial(xlpastevalues) set rgcell = rgcell.offset(1) next rgrow end sub
Comments
Post a Comment