How do I count occurrences of a pattern of data in Excel? -


i realized after manual scanning 90 records, going painful , tedious unless made use of automation.

i have set of data, 4000 records occurs in pattern want track. first column important one. want scan through column , record in new column how man times number has occurred. possible programatically in excel?

note: i'm not looking single pattern or single occurrence of pattern.

e.g. in sample 313 occurs 1 time, 314 occurs 6 times, 315 occurs 2 times, etc.

at end of occurrences want like

--- desired output -------  313 1       343  1 314 1   344   314 2   344  314 3   344 314 4   344 314 5   344   314 1   345  6 315 2   345   315 1   346  2   -- sample data ------------------------------------ 313 1   343 314 1   344 314 2   344 314 3   344 314 4   344 314 5   344 314 1   345 315 2   345 315 1   346 316 2   346 316 1   347 317 2   347 318 1   348 318 2   348 319 1   349 319 2   349 319 3   349   

5/23/13 data delimited spaces. not in 1 cell. don't know how create grid picture here. leftmost cell 1 want counted.

the desired output example of want. there 6 occurrences of 314, want count summary cell compiled in row of last occurrence.

i backed up, slowed down , went basic programming principles, slow feel @ times.

  1. flowchart
  2. pseudocode
  3. prototype
  4. test
  5. repeat 3 , 4 needed.

i found following code did needed. share follow.

sub countfoo() dim startcell range dim precell range dim counter integer dim startpoint range, endpoint range dim filename string, delimitingcharacter string, sqlpre string, sqlpost string dim sql string dim outfile integer  filename = "update_foo.sql" sqlpre = "update foo set foodata = " sqlpost = " details = '" outfile = freefile() open filename output outfile counter = 1  set startpoint = cells(2, 4) startpoint.activate  debug.print "start point:" & startpoint.address debug.print startpoint.value  set startcell = activecell set precell = startcell.offset(-1, 0)   while startcell.value <> "end"  if (startcell.value = precell.value)   counter = counter + 1   set precell = startcell   set startcell = startcell.offset(1, 0) elseif ((startcell.value <> precell.value) or (startcell.value = "end"))   startcell.offset(-1, 3).value = counter   if counter > 1     startcell.offset(-1, 0).interior.color = 5296274     startcell.offset(-1, 1).interior.color = 5296274     startcell.offset(-1, 2).interior.color = 5296274     startcell.offset(-1, 3).font.bold = true     startcell.offset(-1, 3).interior       .pattern = xlgray8       .patterncolor = 65535       .color = 5296274     end   end if   sql = sqlpre & counter & sqlpost & startcell.offset(-1, 0).value & "';"   print #outfile, sql   counter = 1   set precell = startcell   set startcell = startcell.offset(1, 0) end if loop close #outfile end sub 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -