Consulting

Results 1 to 4 of 4

Thread: Solved: Code help

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    Solved: Code help

    I have this code and im getting a
    Compile error:
    End With without with

    Which i have i believe it's because of my If Statements. I hope some one can someone help with.
    [VBA]Private Sub CmdSavePrint_Click()

    LblDate.Caption = Format(Now, "mm/dd/yyyy") & " " & Format(Now, "hh:mm:ss AM/PM")

    'Add New Button to your UserForm so you press to Apply Data to Sheet
    Dim RowNext As Integer

    'last row of data puls one row
    RowNext = Worksheets("Server Build Template").Cells(65536, 1).End(xlUp).Row + 1

    'Cells(Row Number,Column Number)
    With Worksheets("Server Build Template")
    .Cells(RowNext, 1) = TxtName.Value
    .Cells(RowNext, 2) = LblDate.Caption
    .Cells(RowNext, 3) = TxtServerName.Value
    .Cells(RowNext, 4) = TxtLocation.Value

    If Me.ButtonG4 = True Then .Cells(RowNext, 5) = Me.LblML370G4.Caption
    If Me.ButtonG5 = True Then .Cells(RowNext, 5) = Me.LblML370G5.Caption

    .Cells(RowNext, 6) = TxtCtsContact.Value
    .Cells(RowNext, 7) = TxtTracking.Value

    If Me.Button72 = True Then .Cells(RowNext, 8) = Me.Lbl728GB.Caption
    If Me.Button146 = True Then .Cells(RowNext, 8) = Me.Lbl146GB.Caption

    .Cells(RowNext, 9) = TxtDrive1SN.Value
    .Cells(RowNext, 10) = TxtDrive2SN.Value
    .Cells(RowNext, 11) = TxtDrive3SN.Value
    .Cells(RowNext, 12) = TxtDrive4SN.Value

    If Me.ChkBox1721 = True Then
    .Cells(RowNext, 13) = "a"
    .Cells(RowNext, 14) = ServerBuild.TxtR1721.Value

    If Me.ChkBox2811 = True Then
    .Cells(RowNext, 15) = "a"
    .Cells(RowNext, 16) = ServerBuild.TxtR2811.Value

    If Me.ChkBox2620 = True Then
    .Cells(RowNext, 17) = "a"
    .Cells(RowNext, 18) = ServerBuild.TxtR2620.Value

    If Me.Button3550 = True Then
    .Cells(RowNext, 19) = Me.Lbl3550.Caption
    .Cells(RowNext, 20) = ServerBuild.TxtS3550.Value

    If Me.Button3560 = True Then
    .Cells(RowNext, 21) = Me.Lbl3560.Caption
    .Cells(RowNext, 22) = ServerBuild.TxtS3560.Value

    If Me.ChkBoxCSU = True Then
    .Cells(RowNext, 23) = Me.LblCSU.Caption
    .Cells(RowNext, 24) = ServerBuild.TxtVCSU.Value

    .Cells(RowNext, 25) = TxtFinalStatus.Value
    .Cells(RowNext, 26) = TxtSignature.Value
    End With
    ServerBuild.PrintForm

    'You can't save a worksheet
    ActiveWorkbook.Save

    ServerBuild.CmdClear = True


    End Sub[/VBA]

    Any ideas why

  2. #2
    You need to close up all of your if statements. For each If, you need to have an End If.

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Duh i should of realized that thanks works good now.

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Mark your thread solved using the thread tools at the top of the page.....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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