Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Skipping empty rows when copying a formula down a column

When there are gaps in the data so you don't want to use xldown, maybe xlup will
work:

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
range("L4:L" & lastrow).formular1c1 _
= "=RC[-2]+RC[-1]"
end with

I used column A to determine the lastrow. Can you pick a column that always has
data?

If not, maybe you could use something like:
lastcell = .cells.specialcells(xlcelltypelastcell).row

But this often returns a number much higher than you would have guessed.

Rachel Jones wrote:

I am trying to write a macro which will enter a formula into a cell on
the fourth row of a spreadsheet, then copy it down the column -
allowing for the fact that there may be a groups of 2 empty rows at
periods.
My VBA knowledge is poor - I have got the formula copying OK (until it
hits the first empty row) like this:
Range("L4").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Set rng = Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0,
-1).End(xlDown))
Set rng = rng.Offset(0, 1)
rng.Formula = ActiveCell.Formula

but am unsure how to proceed from here.
Any help would be appreciated

Rachel


--

Dave Peterson

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
Copying rows values on one sheet to part of a formula in a column Manosh Excel Discussion (Misc queries) 3 June 23rd 09 03:37 PM
Copying a formula but 'skipping' a cell Mike Langensiepen New Users to Excel 2 May 3rd 07 06:17 AM
Copy formula with skipping rows Fewebber Excel Worksheet Functions 0 June 6th 06 04:12 PM
Copying values but skipping empty cells Handyy Excel Worksheet Functions 1 February 9th 06 01:41 AM
Same formula in each cell of column; insert rows w/o copying down tgdavis Excel Discussion (Misc queries) 3 September 14th 05 09:32 PM


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