Here is my Code:
Sub showUnique()
Dim VAriable As String
Dim irange As Range
Dim car As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Dim inew As Range
Set Source = ActiveSheet
Range("f2").Activate 'starting point
Do
If ActiveCell.Value <> ActiveCell.Offset(1, 0).Value Then
VAriable = ActiveCell.Value
Set irange = Range("f1:f1000")
car = -Application.CountIf(irange, VAriable) + 1
Set inew = Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(car, 0)).EntireRow
'inew.Select
Set Target = Worksheets.Add(after:=Sheets(Sheets.count)) ' after last sheet
Target.Name = VAriable
' 'header row
Source.Range("a1:h1").Copy Target.Range("a1")
'handle Vehicle sales
' Set Target = Worksheets.Add(after:=Source) 'after active shett
' 'copy data
Source.Range(inew).Copy Target.Range("a2")
Target.Range("a1").CurrentRegion.Columns.AutoFit
writeKPI
End If
Sheets("Sales").Activate
ActiveCell.Offset(1, 0).Activate
Loop Until IsEmpty(ActiveCell)
End Sub
Getting the error "Method 'Range' of object '_Worksheet' failed" on the line of code
Source.Range(inew).Copy Target.Range("a2")
I am trying to reference a range on a different worksheet and copy that data to a new worksheet