ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add line with macro selected area (https://www.excelbanter.com/excel-discussion-misc-queries/155365-add-line-macro-selected-area.html)

doral

Add line with macro selected area
 
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.

Steve

Add line with macro selected area
 
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)

"doral" wrote:

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.


Farhad

Add line with macro selected area
 
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,
--
Farhad Hodjat


"doral" wrote:

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.



All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com