Move a whole row to a new worksheet row based on entry in one cell but not if input entry is in another cell

RID

New Member
Joined
Dec 17, 2009
Messages
17
Good afternoon, is there a formula that can be used to do the following, I have a worksheet for reviews that we have internal comments for our own use and responses to customer. I have a sneaky feeling that this will probably need some sort of VBA code but thought I would ask the question if can be done by formula first off. Currently we have that what ever is in column F on worksheet 1 is transferred into worksheet but as you can see when there is no entry in column F it still transfers the row because we have someting in column D.

If there is input in Column F 'Response to Customer' cells I would like to transfer the whole row onto a new worksheet which is the bottom screenshot, but if there is an input in Colum D 'Internal Comment' then the row is not transfered to the second worksheet.

Any pointers would be appreciated if I need to start looking at VBA where should I be looking at and is there specific tutorials that can get me going?

1614689674499.png



1614689851723.png
 
In the workbook you posted, you have macros in all the "Doc" sheets code modules. Start by deleting all these macros. Next place the code below in the code module for ThisWorkbook. Do the following: Hold down the ALT key and press the F11 key. This will open the Visual Basic Editor. In the left hand pane, double click on "ThisWorkbook". Copy/paste the macro into the empty window that opens up. Close the window to return to your sheet. Try entering data in the "Doc" sheets.
VBA Code:
Dim oldVal As Long

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name Like "Doc*" Then
        If Target.CountLarge > 1 Then Exit Sub
        If Target.Column <> 6 Then Exit Sub
        oldVal = Range("A" & Target.Row).Value
    End If
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name Like "Doc*" Then
        Application.ScreenUpdating = False
        Dim num As Long
        num = Split(Sh.Name, " ")(1)
        If Target.CountLarge > 1 Then Exit Sub
        If Target.Column <> 6 Then Exit Sub
        Application.ScreenUpdating = False
        Dim desWS As Worksheet, lRow As Long, fnd As Range
        Set desWS = Sheets("Client " & num)
        lRow = desWS.Range("B" & Rows.Count).End(xlUp).Row
        If Target <> "" Then
            Set fnd = desWS.Range("A:A").Find(oldVal, LookIn:=xlValues, lookat:=xlWhole)
            If fnd Is Nothing Then
                If Target.Offset(, -2) = "" Then
                    With desWS
                        If lRow = 2 Then
                            .Range("A" & lRow + 1).Resize(, 3).Value = Range("A" & Target.Row).Resize(, 3).Value
                            .Range("F" & lRow + 1).Value = Range("F" & Target.Row).Value
                        Else
                            lRow = lRow + 7
                            .Range("A" & lRow).Resize(, 3).Value = Range("A" & Target.Row).Resize(, 3).Value
                            .Range("F" & lRow).Value = Range("F" & Target.Row).Value
                        End If
                    End With
                End If
            Else
                With desWS
                    .Range("A" & fnd.Row).Resize(, 3).Value = Range("A" & Target.Row).Resize(, 3).Value
                    .Range("F" & fnd.Row).Value = Range("F" & Target.Row).Value
                End With
            End If
        Else
            Set fnd = desWS.Range("A:A").Find(oldVal, LookIn:=xlValues, lookat:=xlWhole)
            If Not fnd Is Nothing Then
                desWS.Rows(fnd.Row).ClearContents
            End If
        End If
    End If
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I can now enter everything into the document tab and its transferred into the client document, but what is happening now is that when a row has an internal comment, its taking up a blank row in the client sheet instead of ignoring it
1614848007899.png


1614848026834.png
 
Upvote 0
Delete all the numbers in column A of the "Client" sheets and try again. You don't need those numbers because the macro will insert them.
 
Upvote 0

Forum statistics

Threads
1,214,395
Messages
6,119,265
Members
448,881
Latest member
Faxgirl

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