cutting an entire row and insert it some place else

R23_Wave

New Member
Joined
Nov 1, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
hello all,

i am having some issues with cut an entire row out of my spreadsheet and moving it to a new location. below you will find a sample of the table and then followed by the code i am trying

A B c D
1 Checked First name last name friend signed up
2 Patrick Staten Nick Gross
3 Connor Olson Nick Gross
4 Mary West
5 Nick Gross
6 Mary Troll Sam Lux


the idea is if cell A2 is empty then look at D2 and take that name find it in column B and C then cut row 2 out and insert it below that persons name while also placing "yes" into the A column for that person. so when done it would look like this

A B c D
1 Checked First name last name friend signed up
4 yes Mary West
5 yes Nick Gross
2 yes Patrick Staten Nick Gross
3 yes Connor Olson Nick Gross
6 yes Mary Troll Sam Lux


VBA Code:
Sub Prepare_Click()

Application.ScreenUpdating = False
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Partner As String
Dim FirstPartner As String
Dim LastPartner As String


For i = 3 To 153
   If IsEmpty(Cells(i, 2).Value) = True Then
        If Cells(i, 5).Value <> " " Then
            Partner = Cells(i, 5)
            FirstPartner = Split(Partner, " ")(0)
            LastPartner = Split(Partner, " ")(1)
            For j = 3 To 153
                If Cells(j, 3).Value = FirstPartner Then
                    If Cells(j, 4).Value = LastPartner Then
                        Cells(i, 2).Value = "yes"
                        Range(i).Cut Rows(j).Insert
                    End If
                End If
            Next j
        End If
    End If
Next i
end sub
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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