Add line with macro selected area

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For example I have a macro that sorts data from A1 to D5. Is there a way for
this macro to pick up an extra line. Say I copied row 1, and then pasted it
under row 1, so therefore, I would want the macro to sort from A1 to D6. Is
there a way for the macro to automatically update itself, instead of me going
through all macros to update the selected range? Thank you.
 
You could add a simple routine to count the rows. Assuming data always
present in column "A"

r=1
Do while not IsEmpty(Sheets(".......").Cells(t,1))
r=r+1
Loop
sortRange =("A1:D" & r)
 
Hi,

enter formula below in a cell say E1 and then link the counter in your Macro
to this cell (E1):

=COUNTA(A1:A1000)

assumed column A should not be blank in your data range for example if your
datarange is A1:D100 column A Cells between this range shouldn't be blank

Thanks,
 
Back
Top