Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to set end to create range

I have a worksheet into which a file is imported daily and can vary in the
number of rows it occupies. I then does other things for which I have
recorded a macro, which includes going to the end cell. I use this to create
a range that then does lookups and creates data on another sheet. If the data
imported creates more rows than the sheet I have recorded the macro on I
don't get the extra data copied to the other sheet. I need a macro that will
tell me the last row on the imported sheet to set the end cell for the range
for the rest of my macro. Hopefully this will then "float" and I will always
get all of my data examined and transferred.



Regards
Chris.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Macro to set end to create range

On Mar 12, 8:47 am, Chris M <Chris
wrote:
I have a worksheet into which a file is imported daily and can vary in the
number of rows it occupies. I then does other things for which I have
recorded a macro, which includes going to the end cell. I use this to create
a range that then does lookups and creates data on another sheet. If the data
imported creates more rows than the sheet I have recorded the macro on I
don't get the extra data copied to the other sheet. I need a macro that will
tell me the last row on the imported sheet to set the end cell for the range
for the rest of my macro. Hopefully this will then "float" and I will always
get all of my data examined and transferred.

Regards
Chris.


Chris,

I personally like the CurrentRegion property. Search "currentregion"
in the VBE help and you'll find an explanation of this property. In
short, if your data is contiguous, you can add a .Rows.Count to the
end of CurrentRegion and get the last row of your data set.

Range(x).CurrentRegion.Rows.Count

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Macro to set end to create range

First, your code should clear all the contents of the input sheet (where the
data are imported) before importing. If that's true, then the expression
Worksheets("InputSheet").Range("A1").End(xlDown) will give you the last cell,
assuming contiguous data in culumn A. If not contiguous, you can use
Worksheets("InputSheet").Range("A65536").End(xlUp) . Add ".Row" to either of
these to indicate the row number.

--
* Please click Yes if this was helpful *
Andy Smith
Senior Systems Analyst
Standard and Poor''s, NYC



"Chris M" wrote:

I have a worksheet into which a file is imported daily and can vary in the
number of rows it occupies. I then does other things for which I have
recorded a macro, which includes going to the end cell. I use this to create
a range that then does lookups and creates data on another sheet. If the data
imported creates more rows than the sheet I have recorded the macro on I
don't get the extra data copied to the other sheet. I need a macro that will
tell me the last row on the imported sheet to set the end cell for the range
for the rest of my macro. Hopefully this will then "float" and I will always
get all of my data examined and transferred.



Regards
Chris.

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 do I create a macro that will select a range that can vary in smokief Excel Discussion (Misc queries) 2 May 3rd 07 08:32 PM
How do I create a dynamic range in a macro Mark2122 Excel Worksheet Functions 2 February 2nd 07 09:44 PM
Macro to create/edit calculated fields from a range nc Excel Programming 0 May 15th 06 09:16 AM
Can I create a macro to identify and delete blank rows in a range? carlsondj Excel Programming 6 June 10th 05 12:38 AM
Macro to Create text file from range of cells? Joan Roco[_2_] Excel Programming 1 July 28th 04 07:28 PM


All times are GMT +1. The time now is 11:36 PM.

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

About Us

"It's about Microsoft Excel"