Good afternoon. I know we don't like "Select" but I need to find some way to regain the focus of my starting sheet when executing the following code:-
If I don't "Select" the StartSheet then
Is incorrect as the focus is still on the sheet where the paste took place.
I rather optimistically tried:-
But I get
Any thoughts?
Many thanks,
D€$
Code:
x = 0
With ActiveSheet
StartSheet = .Name
MyUsedRows = .UsedRange.Rows.Count
MyUsedColumns = .UsedRange.Columns.Count
End With
Title = Range("K3")
For a = 3 To MyUsedRows
If Range("K" & a) = Title Then
x = x + 1
Else: 'End of similar items so create a new sheet
With ActiveWorkbook.Sheets
.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Title
End With
Sheets(StartSheet).Range("a" & a - x).Resize(x, MyUsedColumns).Copy
Sheets(Title).Range("A2").PasteSpecial Paste:=xlPasteAll
Sheets(StartSheet).Select
If I don't "Select" the StartSheet then
Code:
x = 0
Title = Range("K" & a)
a = a - 1 'Need to go back 1 row
End If
Next a
Is incorrect as the focus is still on the sheet where the paste took place.
I rather optimistically tried:-
Code:
Sheets(StartSheet).Range("a" & a - x).Resize(x, MyUsedColumns).Copy Destination: Sheets(Title).Range ("A2")
But I get
Code:
Error 1004
The Clipboard cannot be emptied. Another program may be using the clipboard.
Any thoughts?
Many thanks,
D€$