Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How do I create a dynamic range in a macro

I am designing a macro for a user that takes a range of data and moves it
from one column to another and then clears the data from the original column
at the beginning of the day. The problem is that new rows are added every few
days and the range in the macro does not update. This causes data not to be
moved at start of day. I have formulas below the range I want to move so I
can't set the range to large as to clear out the formulas. Does anyone know
how to have the range in the macro change as the range in the worksheet
changes?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,574
Default How do I create a dynamic range in a macro

Create a dynamic named range and then reference that named range in your macro.

Info on dynamic named ranges he
http://www.ozgrid.com/Excel/DynamicRanges.htm

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"Mark2122" wrote:

I am designing a macro for a user that takes a range of data and moves it
from one column to another and then clears the data from the original column
at the beginning of the day. The problem is that new rows are added every few
days and the range in the macro does not update. This causes data not to be
moved at start of day. I have formulas below the range I want to move so I
can't set the range to large as to clear out the formulas. Does anyone know
how to have the range in the macro change as the range in the worksheet
changes?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default How do I create a dynamic range in a macro

If the rows all contain data - i.e., no empty cells - you can use something
along the lines of

dim rngBottom as Range
set rngBottom = range("a1").End(xlDown)

to find the bottom cell in column A. If that row contains your formulas,
and you need to exclude two rows, modify it like so

set rngBottom = range("a1").End(xlDown).offset(-2,0)


Then, to move that data somewhere else

Range("A1", rngBottom).Cut

Range("C1").Select
ActiveSheet.Paste

"Mark2122" wrote:

I am designing a macro for a user that takes a range of data and moves it
from one column to another and then clears the data from the original column
at the beginning of the day. The problem is that new rows are added every few
days and the range in the macro does not update. This causes data not to be
moved at start of day. I have formulas below the range I want to move so I
can't set the range to large as to clear out the formulas. Does anyone know
how to have the range in the macro change as the range in the worksheet
changes?

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
Range Name affecting speed of macro Richard Buttrey Excel Worksheet Functions 5 May 1st 06 03:06 PM
Copy/Paste using a macro that identifies occuoied range JorgeAE Setting up and Configuration of Excel 1 March 13th 06 12:51 AM
Crate group of date, with Dynamic Range in pivot table not working Tiya Excel Discussion (Misc queries) 3 March 1st 06 02:26 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM
Match function...random search? Les Excel Worksheet Functions 10 July 28th 05 11:54 AM


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

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"