Autofill Dynamic Range of Cells

K

KeriM

I'm trying to do an autofill on a dynamic range of cells, and I'm havin
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. Th
starting row value is stored in "i", just not the range of cells that
want to autofill. I tried putting that intersect statement in there, bu
it gave me a "type mismatch" error. Does anyone know what to do? Thanks
 
B

benmcclave

Hi Keri,

This worked for me:

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

-Ben
 
L

Living the Dream

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top