I posted the same question a little while ago and was told that I had spelled sheets wrong. I took the question down; because I thought that I understood I was trying to call a method..that was my range (and yes sheet was spelled sheeet). I guess I still do not understand. I am trying to copy column "A2" through the last cell of column "D" from the sheet "TEXT" to Sheet3
Dim TotalRows As Integer
Dim CurrentWorkbook As Workbook ' macro workbook
Dim RangeToCopy As Range
Dim ColumnLetterNumber As String
Set CurrentWorkbook = ThisWorkbook
TotalRows = Sheets("TEXT").UsedRange.Rows.Count
ColumnLetterNumber = "D" & TotalRows
Set RangeToCopy = Range("A2", ColumnLetterNumber)
' Group Last Observed within the first three columns
' Last Observed start in column N
' After Insert end up in column )
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
' Move the Last observed (now column O) to Column D so that they can be fitered together
Sheets("TEXT").Range(Range("O1"), Range("O1").End(xlDown)).Copy Sheets("TEXT").Range("D1")
With Sheets("TEXT")
.AutoFilterMode = False
.Range("A1:D1").AutoFilter
End With
'
'Copy Columns to the POAM sheet
Set RangeToCopy = Range("A2", ColumnLetterNumber) 'top left, bottom right
RangeToCopy.Select
CurrentWorkbook.Sheets("Sheet3").Activate
CurrentWorkbook.Sheets("TEXT").Range(RangeToCopy).Copy Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet3").Range("A1"), unique:=True
End Sub
I answered your more detailed earlier question. This will not work because this line doesn't work for at least 2 reasons:
First, "RangeToCopy" is not a defined range on the sheet, so you cannot reference it in this way. It is a variable in your VBA code, so you just need to use the Copy Function on this range. Second, the Copy function of the Range Class does not have all of these parameters. You want:
If you are actually tryin get unique values, then you need to use the "AdvancedFilter" function.
Also, you should define RangeToCopy based on the Sheet Name so:
Aren't you over doing this?
(I didn't bother with sheet names)