excel - Count like values then put count in cell -


i'm trying loop through column a- "domains", , total pages per domain. each row, if domain same, count total. once new domain, put final page count in top right box of domain in column c.

enter image description here

i'm new vba- i'm trying this. guidance appreciated.

sub testscript()      imaxrow = 11000     range("b1").select     pagescounter = 0    'loop counter each page in site     countentrycell = 1  'where put total # pages site      irow = 1 imaxrow         'loop through column b, while domain name same... count rows         'then put final count in count column         if activecell = activecell.offset(-1, 0)             pagescounter = pagescounter + 1         else            'copy pages count column c within box         end if         activecell.offset(1, 0).select 'select next row     next irow end sub 

upd:

try one:

sub testscript()     dim lastrow long     dim rng range, c range      'change sheet1 suit     thisworkbook.worksheets("sheet1")         lastrow = .cells(.rows.count, "a").end(xlup).row         set rng = .range("a2:a" & lastrow)          each c in rng             if c.value <> c.offset(-1).value                 'c.offset(,2) gives column c                 c.offset(, 2).value = worksheetfunction.countif(rng, c.value)                 'aplly border                 c.offset(-1).resize(, 3).borders(xledgebottom)                     .linestyle = xlcontinuous                     .colorindex = 0                     .tintandshade = 0                     .weight = xlmedium                 end             end if         next c     end end sub 

result:

enter image description here


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -