Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i lock columns but allow for new rows to be added? Dave Peterson Excel Discussion (Misc queries) 0 August 27th 08 04:08 PM
Sum formulas do NOT expand when rows added ! Blue Max Excel Worksheet Functions 5 April 29th 08 05:13 PM
Identify New Added Rows AnneMarie Excel Worksheet Functions 2 July 10th 07 04:20 PM
Using macro/vba to copy varying ranges of rows BCLivell Excel Discussion (Misc queries) 3 June 6th 07 02:52 PM
Rows added after refresh not in formula Greg Snidow Excel Worksheet Functions 11 November 21st 06 08:32 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"