excel - Counting the number of rows in an non-active sheet -
i have 2 sheets within workbook. sheet 1 calling macro from.
within sheet 2 want loop through rows , print "yes" if sucsessful.
so far have below:
dim totalnumrows long dim norow integer sheets("sheet2") 'get amount of rows within q3 joiners list totalnumrows = .range("b" & .rows.count).end(xlup).row .range("b2").select userrowno = 1 totalnumrows msgbox ("yes") activecell.offset(1, 0).select next end
its calculating amount of rows within sheet 2 error thrown on '.range("b2").select'saying "select method of range class failed"
you can select range on active worksheets
sub main() dim totalnumrows long dim norow integer sheets("sheet2") .activate '<-- activate relevant worksheet 'get amount of rows within q3 joiners list totalnumrows = .range("b" & .rows.count).end(xlup).row .range("b2").select norow = 1 totalnumrows msgbox ("yes") activecell.offset(1, 0).select next end end sub
Comments
Post a Comment