+ Reply to Thread
Results 1 to 3 of 3

report with loops and conditional printing

Hybrid View

  1. #1
    Registered User
    Join Date
    10-25-2017
    Location
    oostende belgium
    MS-Off Ver
    2013
    Posts
    2

    report with loops and conditional printing

    Hi All,

    I'm making a report form in dutch for my work, certain cells have to be filled in that's why i made this program. I want to create a loop so that if something is left blank c5 it loops back until that cell is filled, then it can check if cell f5 is filled in if it is not it has to loop back until this cell is filled.
    the next part is that I want to work with 9 cells which have to be filled in but if one or more of them is filled in it is enough. (probably with or/and)
    the last part is that they should not be able to save the report until everything is filled in.
    Sub Knop6_Klikken()
    If Range("c5").Value = "" Then
    MsgBox "Vul naam in!!!!"
    Else:
    End If
    If Range("f5").Value = "" Then
    MsgBox "Vul begin dienst in!!!!"
    Else:
    End If
    If Range("f6").Value = "" Then
    MsgBox "Vul einde dienst in!!!!"
    Else:
    End If
    If Range("c3").Value = "" Then
    MsgBox "Vul datum in!!!!"
    Else:
    End If
    If Range("f3").Value = "" Then
    MsgBox "Vul shift in!!!!"
    Else: MsgBox "alles ingevuld ok"
    End If
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. It would be very helpful to indent code to show structure. --6StringJazzer
    Last edited by 6StringJazzer; 10-25-2017 at 11:02 AM. Reason: code tags

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: report with loops and conditional printing

    Maybe just count the cells?
    Sub CnT()
        Dim rng As Range
        Set rng = Range("A1,B2,C3,D4,E5,F6,G7,H8,I9")
        If Application.WorksheetFunction.CountA(rng) > 0 Then
            MsgBox "Do Something here"
        Else
            MsgBox "Do something else here"
        End If
    End Sub

  3. #3
    Registered User
    Join Date
    10-25-2017
    Location
    oostende belgium
    MS-Off Ver
    2013
    Posts
    2

    Re: report with loops and conditional printing

    Thanks it worked I now have the following structure. I also hope I did not forget the code tags this time because I don't know what these are yet
    the next thing that needs to be done is loop everything so they can't save the workbook until everything is entered. Meanwhile I'll search the forum for answers.

    Sub Knop6_Klikken()
    If Range("c5").Value = "" Then
    MsgBox "Vul naam in!!!!"
    Else:
    End If
    If Range("f5").Value = "" Then
    MsgBox "Vul begin dienst in!!!!"
    Else:
    End If
    If Range("f6").Value = "" Then
    MsgBox "Vul einde dienst in!!!!"
    Else:
    End If
    If Range("c3").Value = "" Then
    MsgBox "Vul datum in!!!!"
    Else:
    End If
    If Range("f3").Value = "" Then
    MsgBox "Vul shift in!!!!"
    Else:
    End If
    Dim rng As Range
    Set rng = Range("G12,G13,G14,J12,J13,J14,M12,M13,M14")
    If Application.WorksheetFunction.CountA(rng) > 0 Then
    MsgBox "Alles ok"
    Else
    MsgBox "Gelieve het aantal uren bij de IpCode in te vullen"
    End If
    End Sub

+ 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] Report Printing Macro Help
    By jdevans8899 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2012, 10:27 AM
  2. Using loops to set conditional formating
    By abmat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2011, 09:40 PM
  3. Conditional Report Printing
    By pure in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2011, 09:14 AM
  4. VBA loops: conditional copy to another worksheet
    By baucucu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2008, 05:33 AM
  5. Printing a custom report
    By Terrance in forum Excel General
    Replies: 2
    Last Post: 10-19-2007, 10:22 PM
  6. [SOLVED] vba conditional loops
    By Benoit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2006, 12:40 PM
  7. Printing a Report
    By sue74 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2005, 05:13 PM

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