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 copying of rows

This might be very easy question, but very hard for me. I try to do VBA
code where I copy one formula to rows. When I record a macro I get
this code:


Sub uusikopsaus()

Range("C6").Select
Selection.AutoFill Destination:=Range("C6:C20"),
Type:=xlFillDefault
Range("C6:C20").Select
End Sub


This code is okay, but how I should change it such way that range
function get parameters from COUNT function. This is pseudocode, but
idea is this kind of:

Selection.AutoFill Destination:=Range("C6:C[COUNT(C:C)]")

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Dynamic copying of rows

If there's no data in column C, then the count (probably countA()) wouldn't
work. But if there's data in column C, then you're gonna overwrite it?

If you can pick out a column that can be used to determine the last row number,
you can do something like:

dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row 'I used column A
.range("c6").autofill destination:=.range("c6:c" & lastrow)
end with



wrote:

This might be very easy question, but very hard for me. I try to do VBA
code where I copy one formula to rows. When I record a macro I get
this code:

Sub uusikopsaus()

Range("C6").Select
Selection.AutoFill Destination:=Range("C6:C20"),
Type:=xlFillDefault
Range("C6:C20").Select
End Sub

This code is okay, but how I should change it such way that range
function get parameters from COUNT function. This is pseudocode, but
idea is this kind of:

Selection.AutoFill Destination:=Range("C6:C[COUNT(C:C)]")

Thanks in advance


--

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
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Charts and Charting in Excel 0 March 1st 06 01:05 AM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Excel Programming 0 March 1st 06 01:05 AM
copying dynamic size to ms powerpoint confused Excel Worksheet Functions 1 October 17th 05 11:48 AM
Dynamic copying & pasting of rows Chris Bromley Excel Programming 7 February 8th 05 03:43 PM
VBA: copying and inserting a dynamic range JP[_10_] Excel Programming 2 June 1st 04 10:29 PM


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