Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
run a macro which looks at ranges with added rows
I am importing 2 text files into a worksheet and need to update ranges within
the the imported files. The original macro works fine however when the user imports new text files the ranges stay the same as when the original macro was created. looking at the macro in edit mode i see that the original row numbers are hard coded and do not reflect the additional rows. How can i get the macro to recognise the additional rows ? |
#2
Posted to microsoft.public.excel.newusers
|
|||
|
|||
run a macro which looks at ranges with added rows
The Recorder will give you something like:
Sub Macro1() ' ' Macro1 Macro ' Macro recorded 2/19/2009 by James Ravenswood ' ' Range("A1:C11").Select Selection.ClearContents End Sub Clearly the 11 is fixed. You need the code to find the last row if rows are added: Sub Macro2() n = Cells(Rows.Count, "C").End(xlUp).Row Range("A1:C" & n).ClearContents End Sub -- Gary''s Student - gsnu200834 "aussiebob" wrote: I am importing 2 text files into a worksheet and need to update ranges within the the imported files. The original macro works fine however when the user imports new text files the ranges stay the same as when the original macro was created. looking at the macro in edit mode i see that the original row numbers are hard coded and do not reflect the additional rows. How can i get the macro to recognise the additional rows ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can i lock columns but allow for new rows to be added? | Excel Discussion (Misc queries) | |||
Sum formulas do NOT expand when rows added ! | Excel Worksheet Functions | |||
Identify New Added Rows | Excel Worksheet Functions | |||
Using macro/vba to copy varying ranges of rows | Excel Discussion (Misc queries) | |||
Rows added after refresh not in formula | Excel Worksheet Functions |