View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
el dee el dee is offline
external usenet poster
 
Posts: 15
Default Type Mismatch Error

Hi Barb,
Thanks for taking a look. The last line is where I recieve the error. The
Macro is supposed to select the last filled cells in columns A:D and auto
fill to end of filled cells in column "E"

Thanks again...! Still working on it...

LastRow = Range("E").End(xlUp)
Set Range1 = Range(Range("A2"), Range("D65536").End(xlUp).Offset(1, 0))
Range1.Select
Selection.Autofill Destination:=("Range1" & LastRow)



The last Line

"Barb Reinhardt" wrote:

I think I've got most of it, but I don't know what you want to do with the
last line, so can't give a suggestion

Option Explicit

Sub test()
Dim aWS As Excel.Worksheet
Dim LastRow As Long
Dim Range1 As Excel.Range
Dim myRange As Excel.Range

Set aWS = ActiveSheet
LastRow = aWS.Cells(aWS.Rows.Count, 5).End(xlUp).Row
Set myRange = aWS.Range("D" & aWS.Rows.Count).End(xlUp).Offset(1, 0)
Set Range1 = aWS.Range(aWS.Range("A2"), myRange)
Range1.Select


'v~~get an error here now. Not sure what you want to do
Selection.AutoFill Destination:=("Range1" & LastRow)
End Sub

HTH,
Barb Reinhardt

"el dee" wrote:

Hello,
Any ideas on the type misatch error I recieve here?
Sub Autofill()

LastRow = Range("E").End(xlUp)
Set Range1 = Range(Range("A2"), Range("D65536").End(xlUp).Offset(1, 0))
Range1.Select
Selection.Autofill Destination:=("Range1" & LastRow)

End Sub