Mark Alsen
New Member
- Joined
- Oct 7, 2017
- Messages
- 2
Hi Everyone.
I have a problem that if my selection is two lines or less, the two lines are repeated in the paste sheet until the sheet is full. If I select three or more lines it seems to be fine and will only paste and sort the the lines that I have selected. Can anyone help
I have a problem that if my selection is two lines or less, the two lines are repeated in the paste sheet until the sheet is full. If I select three or more lines it seems to be fine and will only paste and sort the the lines that I have selected. Can anyone help
Code:
Sub Macro4()
'
' Macro4 Macro
'
'
Dim ws As Worksheet
Dim mySel As Range
Selection.Copy
Sheets("Sheet2").Select
Range("A5:I16").Select
ActiveSheet.Paste
Range("B5:H16").Sort Key1:=Range("B6:H16"), Order1:=xlAscending, Header:=xlNo
Set keyCell = Range("B5")
Range("B4:B16").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
Rem ActiveSheet.PrintOut
Rem Sheet2.Range("A5:I16").ClearContents
Sheets("Sheet1").Select
End With
End Sub