Mattrick2oo3
New Member
- Joined
- Dec 12, 2016
- Messages
- 5
Posted a thread the other day that got no traction but managed to get something working. The Code below looks for "4 Places", activates that cell, offsets and copies and pastes selection.
Sub Places()
Application.ScreenUpdating = False
Dim ResultCell As Range
Dim UsedRng As Range, LastRow As Long
Set UsedRng = ActiveSheet.UsedRange
Do
Set ResultCell = Sheets("Form3").UsedRange.Find(What:="4 Places", LookIn:=xlFormulas, MatchCase:=False)
LastRow = UsedRng(UsedRng.Cells.Count).Row
If Not ResultCell Is Nothing Then
ResultCell.Activate
ActiveCell.Offset(0, -3).Select
Selection.Copy
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(4, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 3).Activate
ActiveCell.Offset(0, -6).Select
Selection.Copy
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(4, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 6).Activate
ActiveCell.EntireRow.Delete
Else
Exit Do
End If
Loop Until ActiveCell.Row = LastRow + 1
End Sub
Would like to be able to replace the "4" with an integer and have the selected range for paste use that many spaces. Any help would be greatly appreciated.
Thanks,
-Matt
Sub Places()
Application.ScreenUpdating = False
Dim ResultCell As Range
Dim UsedRng As Range, LastRow As Long
Set UsedRng = ActiveSheet.UsedRange
Do
Set ResultCell = Sheets("Form3").UsedRange.Find(What:="4 Places", LookIn:=xlFormulas, MatchCase:=False)
LastRow = UsedRng(UsedRng.Cells.Count).Row
If Not ResultCell Is Nothing Then
ResultCell.Activate
ActiveCell.Offset(0, -3).Select
Selection.Copy
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(4, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 3).Activate
ActiveCell.Offset(0, -6).Select
Selection.Copy
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(4, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 6).Activate
ActiveCell.EntireRow.Delete
Else
Exit Do
End If
Loop Until ActiveCell.Row = LastRow + 1
End Sub
Would like to be able to replace the "4" with an integer and have the selected range for paste use that many spaces. Any help would be greatly appreciated.
Thanks,
-Matt