Easy Find then Move

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
I am trying to find, extract, and move data because of formatting issues:
If any row in Column E starts with F or M, then move the range Col E:N to the range of A:J of the row above row found in.

Sub Move_Data()
With Sheets("Sheet1")
FR = 2
LR = .Cells(Rows.Count, "E").End(xlUp).Row
For x = LR To FR Step -1
If Left(Cells(x, "E"), 1) = "F" Or Left(Cells(x, "E"), 1) = "M" Then
.Cells(x, "E") = Dater
.Cells(x, "F") = Formula
.Cells(x, "G") = Typer
.Cells(x, "H") = Pounder
.Cells(x, "I") = Coder
.Cells(x, "J") = Namer
.Cells(x, "K") = Q1
.Cells(x, "L") = P1
.Cells(x, "M") = A1
.Cells(x, "N") = P2

Dater = .Cells(x - 1, "A")
Formula = .Cells(x - 1, "B")
Typer = .Cells(x - 1, "C")
Pounder = .Cells(x - 1, "D")
Coder = .Cells(x - 1, "E")
Namer = .Cells(x - 1, "F")
Q1 = .Cells(x - 1, "G")
P1 = .Cells(x - 1, "H")
A1 = .Cells(x - 1, "I")
P2 = .Cells(x - 1, "J")
End If

Next x

End With
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this:
Code:
Sub Move_Data()
    Dim FR As Long, LR As Long, x As Long
    With Sheets("Sheet1")
        FR = 3
        LR = .Cells(Rows.Count, "E").End(xlUp).Row
        For x = FR To LR
            If Left(.Cells(x, "E").Value, 1) = "F" Or Left(.Cells(x, "E").Value, 1) = "M" Then
                
                'If any row in Column E starts with F or M, then move the range Col E:N to the range of A:J of the row
                'above row found in.

                .Range("E" & x & ":N" & x).Cut Destination:=.Range("A" & x - 1 & ":J" & x - 1)
            End If
        Next x
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top