+ Reply to Thread
Results 1 to 6 of 6

Range - End if without block if error. merging sheet to sheet data transfer (help)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Range - End if without block if error. merging sheet to sheet data transfer (help)

    Hi all. I have combined several sub routines into one worksheet change. I have the master report (SIGN_IN) and I am transferring Data between 3 other sheets (CREDIT_CARD) (HP_DEPOSIT) and (CAP_PD_DEPOSIT). I keep getting error "End If without Block If" error and augment not required to part of my code using statement Range("O" & Target.Row). I have attached a sample workbook with the sheets. Please help me get this working. All help is appreciated!

    I also have the (HP_DEPOSIT) and (CAP_PD_DEPOSIT) that does not transfer properly. When "RLMO" or "RPMO" is entered into column K if column O is blank ("") then the transfer is to (HP_DEPOSIT) and if column O has "X" then the transfer is to go to (CAP_PD_DEPOSIT) but it all goes to (HP_DEPOSIT). The reason for 3 checks if that sometimes customers will bring in three checks for $50.00 each or sometimes two checks for a total of $150.00 combined so we have to sometimes make multiple entries of the form.
    Again all help is appreciated.

    Private Sub Worksheet_Change(ByVal Target As Range)
    'For Sign In  Sheet1)
    
        Dim Crn As Long         'Row number for CREDIT_CARD sheet
        Dim Cws As Worksheet    'Worksheet CREDIT_CARD
        Dim Hrn As Long         'Row number for HP_DEPOSIT sheet
        Dim Hws As Worksheet    'Worksheet HP_DEPOSIT
        Dim Prn As Long         'Row number for CAP_PD_DEPOSIT sheet
        Dim Pws As Worksheet    'Worksheet CAP_PD_DEPOSIT
        'Dim Brn As Long         'Row number for Bad_Tows sheet (Not in use yet)
        'Dim Bws As Worksheet    'Worksheet Bad_Tows (Not in use yet)
        'Dim Irn As Long         'Row number for 2017_Impounds sheet (Not in use yet)
        'Dim Iws As Worksheet    'Worksheet 2017_Impounds (Not in use yet)
        'Dim Iwb As Workbook     'Master Impound workbook path (Not in use yet)
        Dim Status As String    'String for "Completed - TRACS" on Deposits reports cell "B"
        
            Status = "Completed - TRACS"        'String for "Completed - TRACS" on Deposits reports cell "B"
        
                Set Cws = Sheets("CREDIT_CARD")     'Worksheet CREDIT_CARD
                Set Hws = Sheets("HP_DEPOSIT")      'Worksheet HP_DEPOSIT
                Set Pws = Sheets("CAP_PD_DEPOSIT")  'Worksheet CAP_PD_DEPOSIT
                'Set Bws = Sheets("Bad_Tows")        'Worksheet Bad_Tows (Not in use yet)
                'Set Iws = Sheets("2017_Impounds")   'Worksheet 2017_Impounds (Not in use yet)
                'Path for Workbook IMPOUND SPREADSHEETS all years.XLSM (Not in use yet)
                'Set Iwb = Workbooks("C:\Phoenix HQ Shared\Impounds\IMPOUND SPREADSHEETS\IMPOUND SPREADSHEETS all years.xlsx") (Not in use yet)
        
        If Target.Cells.Count > 1 Then Exit Sub
        If Target.Column = 11 Then
    
            If Target.Value = "" Then Exit Sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLCC" or "RPCC" then copy
            'cells "J", "I", "H", "O" from SIGN_IN to CREDIT_CARD Report Cells "A", "B", "C", "D".
    
            Crn = Cws.Cells(Cws.Rows.Count, "A").End(xlUp).Row + 1
            If Target.Value = "RLCC" Or Target.Value = "RPCC" Then
                Range("J" & Target.Row).Copy Cws.Range("A" & Crn)   'Copy SIGN_IN "J" & Paste to CREDIT_CARD Report "A" Tow Sheet #
                Range("I" & Target.Row).Copy Cws.Range("B" & Crn)   'Copy SIGN_IN "I" & Paste to CREDIT_CARD Report "B" DR #
                Range("H" & Target.Row).Copy Cws.Range("C" & Crn)   'Copy SIGN_IN "H" & Paste to CREDIT_CARD Report "C" Auth. #
                Range("O" & Target.Row).Copy Cws.Range("D" & Crn)   'Copy SIGN_IN "O" & Paste to CREDIT_CARD Report "D" CAP PD ("X") or Not ""
    
            
                End If
        End If
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If Else copy cells "I", "T", "R", "S" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
            
            Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                    Else
                    Range("I" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 1
                    Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 1
                    Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 1
                    Range("T" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
                    Range("R" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 1
                    Range("S" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 1
                
                End If
        End If
        
                If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                        Else
                        Range("U" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 2
                        Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 2
                        Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 2
                        Range("X" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
                        Range("V" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 2
                        Range("W" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 2
                
                End If
        
    
    
                    If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
                
                Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                        Else
                        Range("Y" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 3
                        Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 3
                        Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 3
                        Range("AB" & Target.Row).Copy Hws.Range("D" & Hrn)  'Copy & Paste = Check Amount from SIGN_IN Check 3
                        Range("Z" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 3
                        Range("AA" & Target.Row).Copy Hws.Range("F" & Hrn)  'Copy & Paste = Check # from SIGN_IN Check 3
                
                End If
    
                 
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X" then copy
            'then End If, Else copy cells "I", "T", "R", "S" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("I" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # from SIGN_IN Check 1
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 1
                        Pws.Range("B" & Prn) = Status                       'Copy & Paste = Status String Check 1
                        Range("T" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = Check Amount from SIGN_IN Check 1
                        Range("R" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = Check Name from SIGN_IN Check 1
                        Range("S" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = Check # from SIGN_IN Check 1
                
                End If
      
    
                    If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
            'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("U" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste DR # from SIGN_IN Check 2
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 2
                        Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 2
                        Range("X" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 2
                        Range("V" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 2
                        Range("W" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 2
                
                End If
        
        
                 If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
            'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("Y" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # From SIGN_IN Check 3
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 3
                        Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 3
                        Range("AB" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 3
                        Range("Z" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 3
                        Range("AA" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 3
                
                End If
        
    End Sub

  2. #2
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Range - End if without block if error. merging sheet to sheet data transfer (help)

    Sorry the highlight is not visible this will have the problem code in red.
    Private Sub Worksheet_Change(ByVal Target As Range)
    'For Sign In  Sheet1)
    
        Dim Crn As Long         'Row number for CREDIT_CARD sheet
        Dim Cws As Worksheet    'Worksheet CREDIT_CARD
        Dim Hrn As Long         'Row number for HP_DEPOSIT sheet
        Dim Hws As Worksheet    'Worksheet HP_DEPOSIT
        Dim Prn As Long         'Row number for CAP_PD_DEPOSIT sheet
        Dim Pws As Worksheet    'Worksheet CAP_PD_DEPOSIT
        'Dim Brn As Long         'Row number for Bad_Tows sheet (Not in use yet)
        'Dim Bws As Worksheet    'Worksheet Bad_Tows (Not in use yet)
        'Dim Irn As Long         'Row number for 2017_Impounds sheet (Not in use yet)
        'Dim Iws As Worksheet    'Worksheet 2017_Impounds (Not in use yet)
        'Dim Iwb As Workbook     'Master Impound workbook path (Not in use yet)
        Dim Status As String    'String for "Completed - TRACS" on Deposits reports cell "B"
        
            Status = "Completed - TRACS"        'String for "Completed - TRACS" on Deposits reports cell "B"
        
                Set Cws = Sheets("CREDIT_CARD")     'Worksheet CREDIT_CARD
                Set Hws = Sheets("HP_DEPOSIT")      'Worksheet HP_DEPOSIT
                Set Pws = Sheets("CAP_PD_DEPOSIT")  'Worksheet CAP_PD_DEPOSIT
                'Set Bws = Sheets("Bad_Tows")        'Worksheet Bad_Tows (Not in use yet)
                'Set Iws = Sheets("2017_Impounds")   'Worksheet 2017_Impounds (Not in use yet)
                'Path for Workbook IMPOUND SPREADSHEETS all years.XLSM (Not in use yet)
                'Set Iwb = Workbooks("C:\Phoenix HQ Shared\Impounds\IMPOUND SPREADSHEETS\IMPOUND SPREADSHEETS all years.xlsx") (Not in use yet)
        
        If Target.Cells.Count > 1 Then Exit Sub
        If Target.Column = 11 Then
    
            If Target.Value = "" Then Exit Sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLCC" or "RPCC" then copy
            'cells "J", "I", "H", "O" from SIGN_IN to CREDIT_CARD Report Cells "A", "B", "C", "D".
    
            Crn = Cws.Cells(Cws.Rows.Count, "A").End(xlUp).Row + 1
            If Target.Value = "RLCC" Or Target.Value = "RPCC" Then
                Range("J" & Target.Row).Copy Cws.Range("A" & Crn)   'Copy SIGN_IN "J" & Paste to CREDIT_CARD Report "A" Tow Sheet #
                Range("I" & Target.Row).Copy Cws.Range("B" & Crn)   'Copy SIGN_IN "I" & Paste to CREDIT_CARD Report "B" DR #
                Range("H" & Target.Row).Copy Cws.Range("C" & Crn)   'Copy SIGN_IN "H" & Paste to CREDIT_CARD Report "C" Auth. #
                Range("O" & Target.Row).Copy Cws.Range("D" & Crn)   'Copy SIGN_IN "O" & Paste to CREDIT_CARD Report "D" CAP PD ("X") or Not ""
    
            
                End If
        End If
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If Else copy cells "I", "T", "R", "S" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
            
            Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                    Else
                    Range("I" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 1
                    Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 1
                    Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 1
                    Range("T" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
                    Range("R" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 1
                    Range("S" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 1
                
                End If
        End If
        
                If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                        Else
                        Range("U" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 2
                        Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 2
                        Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 2
                        Range("X" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
                        Range("V" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 2
                        Range("W" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 2
                
                End If
        
    
    
                    If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
            'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
                
                Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then End If
                        Else
                        Range("Y" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 3
                        Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 3
                        Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 3
                        Range("AB" & Target.Row).Copy Hws.Range("D" & Hrn)  'Copy & Paste = Check Amount from SIGN_IN Check 3
                        Range("Z" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 3
                        Range("AA" & Target.Row).Copy Hws.Range("F" & Hrn)  'Copy & Paste = Check # from SIGN_IN Check 3
                
                End If
    
                 
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X" then copy
            'then End If, Else copy cells "I", "T", "R", "S" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("I" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # from SIGN_IN Check 1
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 1
                        Pws.Range("B" & Prn) = Status                       'Copy & Paste = Status String Check 1
                        Range("T" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = Check Amount from SIGN_IN Check 1
                        Range("R" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = Check Name from SIGN_IN Check 1
                        Range("S" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = Check # from SIGN_IN Check 1
                
                End If
      
    
                    If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
            'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("U" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste DR # from SIGN_IN Check 2
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 2
                        Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 2
                        Range("X" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 2
                        Range("V" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 2
                        Range("W" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 2
                
                End If
        
        
                 If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
            'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
            'and form date into "C".
    
                Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
                    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then End If
                        Else
                        Range("Y" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # From SIGN_IN Check 3
                        Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 3
                        Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 3
                        Range("AB" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 3
                        Range("Z" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 3
                        Range("AA" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 3
                
                End If
        
    End Sub

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Range - End if without block if error. merging sheet to sheet data transfer (help)

    This will compile, though I'm not sure it'll do everything you want - might help to see the original code you are trying to combine into one.

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    'For Sign In  Sheet1)
    
    Dim Crn As Long         'Row number for CREDIT_CARD sheet
    Dim Cws As Worksheet    'Worksheet CREDIT_CARD
    Dim Hrn As Long         'Row number for HP_DEPOSIT sheet
    Dim Hws As Worksheet    'Worksheet HP_DEPOSIT
    Dim Prn As Long         'Row number for CAP_PD_DEPOSIT sheet
    Dim Pws As Worksheet    'Worksheet CAP_PD_DEPOSIT
    'Dim Brn As Long         'Row number for Bad_Tows sheet (Not in use yet)
    'Dim Bws As Worksheet    'Worksheet Bad_Tows (Not in use yet)
    'Dim Irn As Long         'Row number for 2017_Impounds sheet (Not in use yet)
    'Dim Iws As Worksheet    'Worksheet 2017_Impounds (Not in use yet)
    'Dim Iwb As Workbook     'Master Impound workbook path (Not in use yet)
    Dim Status As String    'String for "Completed - TRACS" on Deposits reports cell "B"
    
    Status = "Completed - TRACS"        'String for "Completed - TRACS" on Deposits reports cell "B"
    
    Set Cws = Sheets("CREDIT_CARD")     'Worksheet CREDIT_CARD
    Set Hws = Sheets("HP_DEPOSIT")      'Worksheet HP_DEPOSIT
    Set Pws = Sheets("CAP_PD_DEPOSIT")  'Worksheet CAP_PD_DEPOSIT
    'Set Bws = Sheets("Bad_Tows")        'Worksheet Bad_Tows (Not in use yet)
    'Set Iws = Sheets("2017_Impounds")   'Worksheet 2017_Impounds (Not in use yet)
    'Path for Workbook IMPOUND SPREADSHEETS all years.XLSM (Not in use yet)
    'Set Iwb = Workbooks("C:\Phoenix HQ Shared\Impounds\IMPOUND SPREADSHEETS\IMPOUND SPREADSHEETS all years.xlsx") (Not in use yet)
    
        If Target.Cells.Count > 1 Then Exit Sub
        
        If Target.Column = 11 Then
    
            If Target.Value = "" Then Exit Sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLCC" or "RPCC" then copy
            'cells "J", "I", "H", "O" from SIGN_IN to CREDIT_CARD Report Cells "A", "B", "C", "D".
    
            Crn = Cws.Cells(Cws.Rows.Count, "A").End(xlUp).Row + 1
            
            If Target.Value = "RLCC" Or Target.Value = "RPCC" Then
                Range("J" & Target.Row).Copy Cws.Range("A" & Crn)   'Copy SIGN_IN "J" & Paste to CREDIT_CARD Report "A" Tow Sheet #
                Range("I" & Target.Row).Copy Cws.Range("B" & Crn)   'Copy SIGN_IN "I" & Paste to CREDIT_CARD Report "B" DR #
                Range("H" & Target.Row).Copy Cws.Range("C" & Crn)   'Copy SIGN_IN "H" & Paste to CREDIT_CARD Report "C" Auth. #
                Range("O" & Target.Row).Copy Cws.Range("D" & Crn)   'Copy SIGN_IN "O" & Paste to CREDIT_CARD Report "D" CAP PD ("X") or Not ""
    
    
            End If
        End If
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
        'then End If Else copy cells "I", "T", "R", "S" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
    
        Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then
        Else
            Range("I" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 1
            Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 1
            Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 1
            Range("T" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
            Range("R" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 1
            Range("S" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 1
    
        End If
    
    
        If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
        'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
        Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then
        Else
            Range("U" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 2
            Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 2
            Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 2
            Range("X" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
            Range("V" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 2
            Range("W" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 2
    
        End If
    
    
    
        If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X"
        'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to HP_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
        Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) = "X" Then
        Else
            Range("Y" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 3
            Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 3
            Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 3
            Range("AB" & Target.Row).Copy Hws.Range("D" & Hrn)  'Copy & Paste = Check Amount from SIGN_IN Check 3
            Range("Z" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 3
            Range("AA" & Target.Row).Copy Hws.Range("F" & Hrn)  'Copy & Paste = Check # from SIGN_IN Check 3
    
        End If
    
    
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X" then copy
        'then End If, Else copy cells "I", "T", "R", "S" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
        Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then
        Else
            Range("I" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # from SIGN_IN Check 1
            Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 1
            Pws.Range("B" & Prn) = Status                       'Copy & Paste = Status String Check 1
            Range("T" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = Check Amount from SIGN_IN Check 1
            Range("R" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = Check Name from SIGN_IN Check 1
            Range("S" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = Check # from SIGN_IN Check 1
    
        End If
    
    
        If Range("U" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "U" if blank then exit sub
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
        'then End If, Else copy cells "U", "X", "V", "W" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
        Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then
        Else
            Range("U" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste DR # from SIGN_IN Check 2
            Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 2
            Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 2
            Range("X" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 2
            Range("V" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 2
            Range("W" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 2
    
        End If
    
        If Range("Y" & Target.Row) = "" Then Exit Sub   'Checks for DR # in cell "Y" if blank then exit sub
    
        'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) <> "X"
        'then End If, Else copy cells "Y", "AB", "Z", "AA" from SIGN_IN to CAP_PD_DEPOSIT Report Cells "A", "E", "F" enter Status String in cell "B"
        'and form date into "C".
    
        Prn = Pws.Cells(Pws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) <> "X" Then
        Else
            Range("Y" & Target.Row).Copy Pws.Range("A" & Prn)   'Copy & Paste = DR # From SIGN_IN Check 3
            Range("B2").Copy Pws.Range("C" & Prn)               'Copy & Paste = Form Date from SIGN_IN Check 3
            Pws.Range("B" & Prn) = Status                        'Copy & Paste = Status String Check 3
            Range("AB" & Target.Row).Copy Pws.Range("D" & Prn)   'Copy & Paste = From Check Amount from SIGN_IN Check 3
            Range("Z" & Target.Row).Copy Pws.Range("E" & Prn)   'Copy & Paste = From Check Name from SIGN_IN Check 3
            Range("AA" & Target.Row).Copy Pws.Range("F" & Prn)   'Copy & Paste = From Check # from SIGN_IN Check 3
    
        End If
    
    End Sub
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Range - End if without block if error. merging sheet to sheet data transfer (help)

    This is what I started with, it was to copy data from our master Sign In sheet to our Credit card report. All listed in column K with "RLCC" or "RPCC" was to copy columns J, I, H, O from Sign In to columns A, B, C, D on Credit Card report. This is the code that was working for that perfectly:

    Private Sub Worksheet_Change(ByVal Target As Range)
    'For Sign In  Sheet1)
    
    Dim Crn As Long         'Row number for CREDIT_CARD sheet
    Dim Cws As Worksheet    'Worksheet CREDIT_CARD
    Dim Hrn As Long         'Row number for HP_DEPOSIT sheet
    Dim Hws As Worksheet    'Worksheet HP_DEPOSIT
    Dim Status As String    'String for "Completed - TRACS" on Deposits reports cell "B"
    
    Status = "Completed - TRACS"        'String for "Completed - TRACS" on Deposits reports cell "B"
    
    Set Cws = Sheets("CREDIT_CARD")     'Worksheet CREDIT_CARD
    Set Hws = Sheets("HP_DEPOSIT")      'Worksheet HP_DEPOSIT
    
        If Target.Cells.Count > 1 Then Exit Sub
        
        If Target.Column = 11 Then
    
            If Target.Value = "" Then Exit Sub
    
            'When entering data in a cell in SIGN_IN sheet Col K, If it has value of "RLCC" or "RPCC" then copy
            'cells "J", "I", "H", "O" from SIGN_IN to CREDIT_CARD Report Cells "A", "B", "C", "D".
    
            Crn = Cws.Cells(Cws.Rows.Count, "A").End(xlUp).Row + 1
            
            If Target.Value = "RLCC" Or Target.Value = "RPCC" Then
                Range("J" & Target.Row).Copy Cws.Range("A" & Crn)   'Copy SIGN_IN "J" & Paste to CREDIT_CARD Report "A" Tow Sheet #
                Range("I" & Target.Row).Copy Cws.Range("B" & Crn)   'Copy SIGN_IN "I" & Paste to CREDIT_CARD Report "B" DR #
                Range("H" & Target.Row).Copy Cws.Range("C" & Crn)   'Copy SIGN_IN "H" & Paste to CREDIT_CARD Report "C" Auth. #
                Range("O" & Target.Row).Copy Cws.Range("D" & Crn)   'Copy SIGN_IN "O" & Paste to CREDIT_CARD Report "D" CAP PD ("X") or Not ""
    
    
            End If
        End If
    
        'When entering data in a cell in SIGN_IN sheet Col K, if it has value of "RLMO" or "RPMO" And Range("O" & Target.Row) = "X" then End If , Else copy cells "I", "B2", "T", "R", "S" from SIGN_IN to HP_DEPOSIT Report Cells "A", "C", "D", "E", "F" enter Status String in cell "B".
       
        Hrn = Hws.Cells(Hws.Rows.Count, "A").End(xlUp).Row + 1
        
        If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) =  "X" Then  End If
        Else
            Range("I" & Target.Row).Copy Hws.Range("A" & Hrn)   'Copy & Paste = DR # from SIGN_IN Check 1
            Range("B2").Copy Hws.Range("C" & Hrn)               'Copy & Paste = Form Date from SIGN_IN Check 1
            Hws.Range("B" & Hrn) = Status                       'Copy & Paste = Status String Check 1
            Range("T" & Target.Row).Copy Hws.Range("D" & Hrn)   'Copy & Paste = Check Amount from SIGN_IN Check 2
            Range("R" & Target.Row).Copy Hws.Range("E" & Hrn)   'Copy & Paste = Check Name from SIGN_IN Check 1
            Range("S" & Target.Row).Copy Hws.Range("F" & Hrn)   'Copy & Paste = Check # from SIGN_IN Check 1
    
        End If
    The problem started when I tried to add the routine to add copying the second and third checks to the HP Deposit routine. We need to do this because we sometimes have people come in with two or three checks for the total amount of $150.00. After the first check was entered I wanted column U checked if it is blank to End If, if it is not blank to copy cells U, B2, X, V, W from Sign In to HP Deposit cells A, C, D, E, F and insert String into cell B then check cell Y on Sign In if it is blank then End If, if not start routine for third check entry. Copy cells Y, B2, AB, Z, AA from Sign In to HP Deposit cells A, C, D, E, F and insert String into cell B.

    After I get that routine to work I need to the same routine to run copying the same cells from Sign In to the CAP PD DEPOSIT if the Sign In column O has "X".
    Thank you for your help.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Range - End if without block if error. merging sheet to sheet data transfer (help)

    Hi,

    There should not be an End If on the end of this line
    If Target.Value = "RLMO" Or Target.Value = "RPMO" And Range("O" & Target.Row) =  "X" Then  End If
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Range - End if without block if error. merging sheet to sheet data transfer (help)

    I came at this from a different angle and added two new selections to the column k to be only for the second deposit sheet. Thanks again for all the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Transfer data from sheet to other sheet, protecting the second sheet.
    By Markcassar123 in forum Excel General
    Replies: 4
    Last Post: 06-25-2015, 02:05 AM
  2. [SOLVED] Issue regarding recorded Macro to transfer data from Input sheet to Storage sheet
    By Hirad001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2015, 04:26 PM
  3. How to transfer data from a daily input sheet to a separate monthly total sheet
    By Jcooper71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2014, 02:37 PM
  4. [SOLVED] transfer a selected range of data on one sheet to another workbook
    By Ask Steve in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-23-2013, 01:36 PM
  5. Transfer inputed Data from Sheet x: row x to Sheet y : row y or Sheet z: row z
    By Joecruz749 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2013, 03:20 PM
  6. Replies: 1
    Last Post: 02-13-2013, 01:32 PM
  7. Replies: 0
    Last Post: 09-12-2012, 02:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1