+ Reply to Thread
Results 1 to 8 of 8

VBA Compile Error: Expected End With

Hybrid View

  1. #1
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,946

    Re: VBA Compile Error: Expected End With

    Nest your code; then you can see where you need End Ifs and Loops

    Private Sub cmdOK_Click()
        ActiveWorkbook.Sheets("Change Request Form").Activate
        Range("A1").Select
    Do
        If IsEmpty(ActiveCell) = False Then
            ActiveCell.Offset(1, 0).Select
        End If
        
    Loop Until IsEmpty(ActiveCell) = True
    
            ActiveCell.Value = txtCCTC.Value
            ActiveCell.Offset(0, 2) = txtCustomer.Value
            ActiveCell.Offset(0, 3) = txtInitiator.Value.Value
            ActiveCell.Offset(0, 4) = txtDocumentAffected.Value
        
            If optScrapReduction = True Then
                ActiveCell.Offset(0, 5).Value = "Scrap Reduction"
            ElseIf optLaborReduction = True Then
                ActiveCell.Offset(0, 5).Value = "Labor Reduction"
            ElseIf optVariationReduction = True Then
                ActiveCell.Offset(0, 5).Value = "Variation Reduction"
            ElseIf optCustomerSpecificationChange = True Then
                ActiveCell.Offset(0, 5).Value = "Customer Specification Change"
            ElseIf optReworkReduction = True Then
                ActiveCell.Offset(0, 5).Value = "Rework Reduction"
            ElseIf optMaterialReduction = True Then
                ActiveCell.Offset(0, 5).Value = "Material Reduction"
            ElseIf optEditorial = True Then
                ActiveCell.Offset(0, 5).Value = "Editorial"
            ElseIf optOther = True Then
                ActiveCell.Offset(0, 6).Value = "Other"
            End If
        
            If chkYes = True Then
                ActiveCell.Offset(0, 10).Value = "Yes"
            ElseIf chkNo = True Then
                ActiveCell.Offset(0, 10).Value = "No"
            End If
        
            If chkYes = True Then
                ActiveCell.Offset(0, 11).Value = "Yes"
            Else
                ActiveCell.Offset(0, 11).Value = "No"
            End If
            
            If chkYes = True Then
                ActiveCell.Offset(0, 13).Value = "Yes"
            Else
                ActiveCell.Offset(0, 13).Value = "No"
                
                If chkYes = True Then
                    ActiveCell.Offset(0, 13).Value = "Yes"
                Else
                    ActiveCell.Offset(0, 14).Value = "No"
        
                    If chkYes = True Then
                        ActiveCell.Offset(0, 14).Value = "Yes"
                    Else
                        ActiveCell.Offset(0, 14).Value = "No"
                    End If
        
        Range("A1").Select
    
    End Sub

    I'd say you're missing a couple of End If statements

    Regards
    Last edited by TMS; 11-23-2011 at 06:44 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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