Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Posts: 70
Default Autofill Dynamic Range of Cells

I'm trying to do an autofill on a dynamic range of cells, and I'm having some trouble. Here is what I have so far:

Code:
Range("CR2:DC2").Select
i = Selection.End(xlDown).Row
Intersect(Range("CR:DC"), Rows(i)).Select

LastRow = ActiveSheet.Range("A1").End(xlDown).Row
        Selection.Autofill Destination:=Range( ? & LastRow)
I'm not sure what to put as my starting range in the autofill. The starting row value is stored in "i", just not the range of cells that I want to autofill. I tried putting that intersect statement in there, but it gave me a "type mismatch" error. Does anyone know what to do? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Autofill Dynamic Range of Cells

Hi Keri,

This worked for me:

LastRow = ActiveSheet.Range("A1").End(xlDown).Row
Range("CR2:DC2").AutoFill Destination:=Range("CR2:DC" & LastRow)

-Ben
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Autofill Dynamic Range of Cells

Hi

I maybe on the wrong track here but try this.

Sub Copy_myRng()

Dim SS As Worksheet 'Source
Dim TS As Worksheet 'Target
Dim mySrng As Range
Dim myTrng As Range

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set SS = Sheets("Sheet1")
Set mySrng = SS.Range("CR2:DC2")
Set TS = Sheets("Sheet2")
Set myTrng = TS.Range("A1")

With mySrng
.Copy Destination:=myTrng
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub


HTH
Mick.
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
Autofill Dynamic Range Fester[_2_] Excel Programming 1 December 8th 08 04:04 PM
Dynamic range for autofill macro Jim G Excel Discussion (Misc queries) 2 April 23rd 07 05:46 AM
making autofill range dynamic sonang Excel Programming 0 September 1st 04 10:59 PM
autofill with dynamic range Bernie Deitrick[_2_] Excel Programming 0 September 16th 03 02:55 PM
autofill with dynamic range again a Excel Programming 0 September 16th 03 12:26 PM


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