Consulting

Results 1 to 3 of 3

Thread: Excel VBA to print 3 copies of sheet if it finds something in cell A2.

  1. #1

    Excel VBA to print 3 copies of sheet if it finds something in cell A2.

    Hy guys,

    I have an Excel file that has 9 sheets (F1, F2, F3, F4, F5, F6, F7, F8, F9)

    I have one of the following situations:

    1. F1 has data in cell A2 & F2, F3, F4, F5, F6, F7, F8, F9 are empty
    - I want to print F1 3 times (3 copies)

    2. F1, F2 have data in cell A2 and F3, F4, F5, F6, F7, F8, F9 are empty
    - I want to print F1, F2 3 times (3 copies)

    3. F1, F2, F3 have data in cell A2 and F4, F5, F6, F7, F8, F9 are empty
    - I want to print F1, F2, F3 3 times (3 copies)

    4. F1, F2, F3, F4 have data in cell A2 and F5, F6, F7, F8, F9 are empty
    - I want to print F1, F2, F3, F4 3 times (3 copies)

    5. F1, F2, F3, F4, F5 have data in cell A2 and F6, F7, F8, F9 are empty
    - I want to print F1, F2, F3, F4, F5 3 times (3 copies)

    6. F1, F2, F3, F4, F5, F6 have data in cell A2 and F7, F8, F9 are empty
    - I want to print F1, F2, F3, F4, F5, F6 3 times (3 copies)

    7. F1, F2, F3, F4, F5, F6, F7 have data in cell A2 and F8, F9 are empty
    - I want to print F1, F2, F3, F4, F5, F6, F7 3 times (3 copies)

    8. F1, F2, F3, F4, F5, F6, F7, F8 have data in cell A2 and F9 are empty
    - I want to print F1, F2, F3, F4, F5, F6, F7, F8 3 times (3 copies)

    9. F1, F2, F3, F4, F5, F6, F7, F8, F9 have data in cell A2
    - I want to print F1, F2, F3, F4, F5, F6, F7, F8, F9 3 times (3 copies)


    I need to make a VBA code that annalizes which is the correct situation and then prints the data.

    Any help would be greatly appreciated.
    Thanks a lot guys and have a nice day.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Something like

    With Worksheets("F1")
    
    	If .Range("F1").Value <> "" And _
    .Range("A2").Value = "" And .Range("F2").Value = ""  And .Range("F3").Value = "" And _
    		.Range("F4").Value = "" And .Range("F4").Value = "" And .Range("F6").Value ="" And 
    		.Range("F7").Value = "" And .Range("F8").Value = "" And .Range("F9").Value ="" Then
    		
    			.Printout Copies:=3
    	End If
    End With
    
    'etc.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks a lot man.

Posting Permissions

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