#1   Report Post  
Hirsch
 
Posts: n/a
Default Macro Filldown

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize(, 1)
Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


Above is a simple macro filling down a formula from cell F5. I'm running
into a problem where it exceeds my list by 4 lines. How can I prevent this.
My goal is to have rows 1-4 blank and the fill down end at the last piece of
information.

Thanks in advance.
  #2   Report Post  
Duke Carey
 
Posts: n/a
Default

Change your resize command from

..Resize(, 1) to
..Resize(usedrange.rows.count-4, 1)


"Hirsch" wrote:

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize(, 1)
Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


Above is a simple macro filling down a formula from cell F5. I'm running
into a problem where it exceeds my list by 4 lines. How can I prevent this.
My goal is to have rows 1-4 blank and the fill down end at the last piece of
information.

Thanks in advance.

  #3   Report Post  
Hirsch
 
Posts: n/a
Default

I'm not sure what the error is in the formula. I've applied the resize used
range componnent but now get an error. Listed below is what now have. Did I
miss anything?

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize
UsedRange.Rows.Count - 4, 1)

Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


"Hirsch" wrote:

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize(, 1)
Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


Above is a simple macro filling down a formula from cell F5. I'm running
into a problem where it exceeds my list by 4 lines. How can I prevent this.
My goal is to have rows 1-4 blank and the fill down end at the last piece of
information.

Thanks in advance.

  #4   Report Post  
Duke Carey
 
Posts: n/a
Default

try

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5). _
Resize( activesheet.UsedRange.Rows.Count - 4, 1)

Sorry about not catching that on the first go-round

"Hirsch" wrote:

I'm not sure what the error is in the formula. I've applied the resize used
range componnent but now get an error. Listed below is what now have. Did I
miss anything?

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize
UsedRange.Rows.Count - 4, 1)

Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


"Hirsch" wrote:

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize(, 1)
Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


Above is a simple macro filling down a formula from cell F5. I'm running
into a problem where it exceeds my list by 4 lines. How can I prevent this.
My goal is to have rows 1-4 blank and the fill down end at the last piece of
information.

Thanks in advance.

  #5   Report Post  
Hirsch
 
Posts: n/a
Default

Duke,

that was the missing component. Thank you

"Duke Carey" wrote:

try

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5). _
Resize( activesheet.UsedRange.Rows.Count - 4, 1)

Sorry about not catching that on the first go-round

"Hirsch" wrote:

I'm not sure what the error is in the formula. I've applied the resize used
range componnent but now get an error. Listed below is what now have. Did I
miss anything?

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize
UsedRange.Rows.Count - 4, 1)

Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


"Hirsch" wrote:

Dim rngDataRange As Range

Set rngDataRange = ActiveSheet.UsedRange.Offset(4, 5).Resize(, 1)
Cells(5, 6).Copy rngDataRange.Cells(1, 1)
rngDataRange.FillDown

End Sub


Above is a simple macro filling down a formula from cell F5. I'm running
into a problem where it exceeds my list by 4 lines. How can I prevent this.
My goal is to have rows 1-4 blank and the fill down end at the last piece of
information.

Thanks in advance.

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
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Macro and sub rountines The Good Deeds Team Excel Discussion (Misc queries) 1 March 23rd 05 11:26 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


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