Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Cell References

The simple explanation...

In Excel 2002, I need to select/highlight the cells for column M
through U on whatever row I'm on - the row varys from month to month so
it has to be dynamic and so far all I've figure out in VBA is
hardcoding...

Also, if you could include the way to go down one row from the bottom
that would solve most of the static grand total line problems around
the office. :)


Extra info...

I'm running a report in Excel every month. It pulls the data from an
SQL Query which varies from month to month in length. Since I'm trying
to remove all human hands from this process I'm trying to get Excel to
recognize the size each time it runs. The data is a solid block in the
first 12 columns (A-L) and columns M-U are used for data entered later
and formulas. So I'm working on this part of the macro so it will copy
the formulas in M2 through U2, highlight M2 (or 3) through U(last row)
and paste in the copied formulas. Here's the code I'm trying:

Sub DynamicPasting2()
Range("M2:U2").Select << Cells with formulas
Selection.Copy
Range("L2").Select << Far right column with data on every row
Selection.End(xlDown).Select
Range("M207:U207").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
End Sub

Obviously, The trouble is the Range("M207:U207").Select line - I need
it to select the M through U cells on the bottom row - which isn't
always 207. I guess I just don't know how to select without absolute
references in VBA.

Thanks,
Jordan


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Dynamic Cell References

You can do this with a single line of code (it may be wordwrapped on
screen):

Range("M2:U2").Copy Range(Range("L2"), Range("L2").End(xlDown)).Offset(0,
1)

This is an example of a macro doing something programmatically rather than
in terms of how you do it manually. After you wrestle with a few of these
you'll get the hang of it.

--
Jim Rech
Excel MVP


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
Dynamic Cell References in Excel nogga Excel Discussion (Misc queries) 2 March 23rd 09 07:21 PM
Excel VBA, dynamic references [email protected] Excel Discussion (Misc queries) 6 November 26th 07 01:35 PM
Dynamic formulas including worksheet references lars22222 Excel Worksheet Functions 1 July 26th 05 02:33 PM
dynamic cell references excel novice Excel Worksheet Functions 2 July 12th 05 02:59 PM
Dynamic references in diagram source data? Olzki Excel Discussion (Misc queries) 0 March 1st 05 08:33 AM


All times are GMT +1. The time now is 01:53 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"