LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default xlDown going further than data

I have a macro in excel that fills a formula in the first cell in a
column, then copies that formula and fills it into the rest of the
column. There is placeholder data in this column, so that the formula
will only be copied to a certain amount of cells. My code looks like
this:

Range("P2").Select
ActiveCell.FormulaR1C1 = "=Miles(RC[-10],RC[-5])"
Range("P2").Select
Selection.Copy
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Now the code works fine, but for some reason it pastes the formula well
past the data that is in the column (ex. if data is in rows 1-42, the
formula gets copied to rows 1-112) which gives me a bunch of "#N/A"s,
which causes problems when I try to sum up these values. Any idea why
this is happening? I thought putting in "xlDown" was supposed to
prevent this problem...

 
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
End(xlDown) won't work mike Excel Programming 12 September 16th 06 08:50 AM
xlDown stops at next empty cell, not at last row of data Ronny Hamida Excel Programming 5 June 15th 06 01:14 PM
repeated end(xldown) R.VENKATARAMAN Excel Programming 6 December 28th 05 06:43 PM
XlDown: Go to next blank row tomwashere2 Excel Programming 2 August 16th 05 11:15 PM
xldown and xlright He4Giv Excel Programming 2 January 29th 04 12:41 AM


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