• custom printing with checkbox (2003)

    Author
    Topic
    #427292

    Hello Everyone,
    I need some help doing a macro or VB command to print only the selected columns. I am attaching a document that I would like to print. I would like to create a checkbox in column b2, b3 and forward that a user can check and base on that print only the columns selected. I would also like to hide the second row so the checkbox is not display when printing. Any help would be great. Thanks

    Viewing 1 reply thread
    Author
    Replies
    • #989666

      Do you really mean check boxes in B2, B3, etc., or did you actually mean B2, C2, D2 etc.?

      • #989669

        I would like a checkbox in each cell in row2 (ex: b2,b3,b4,b5,etc.) so they can select the column.My idea would be to print only the ones that are selected by the user. Thanks.

    • #989670

      So many check boxes is a bit much. Why not simply let the user enter an “x” in the cells in row 2 in the columns to be printed? You could then use the following macro:

      Sub PrintSheet()
      Dim intCol As Integer
      Dim intLastCol As Integer
      With Worksheets(“Sheet1”)
      intLastCol = .Cells(1, 2).End(xlToRight).Column
      For intCol = 2 To intLastCol
      .Cells(1, intCol).EntireColumn.Hidden = Not (.Cells(2, intCol) = “x”)
      Next intCol
      .Range(“A2”).EntireRow.Hidden = True
      .PrintOut ‘ or .PrintPreview
      .Range(“A2”).EntireRow.Hidden = False
      .Range(.Cells(1, 2), .Cells(1, intLastCol)).EntireColumn.Hidden = False
      End With
      End Sub

      • #989695

        Thanks Hans I will try that and see if it works.

        • #989805

          Hello Hans,
          I was trying to use the code above to do what aaaofpmch wanted to do, but if there is a gap in the rows where there is an x, the columns do not get hidden. Any ideas as to why? For example, if I select row 2 column a,b,c,d,u, etc. The columns between d and u do not hide and there is a big gap in between them. Any help would be great. Thanks

          • #989808

            Aren’t you the same person as aaaofmpch?

            Try the attached version of your workbook. Click the button to preview only the selected columns.

            • #989811

              Yes I am. I don’t have my password with me, so I ended up creating another account. By the way, I really want to thank you for all your help.

            • #989818

              Does the version I attached do what you want?

    Viewing 1 reply thread
    Reply To: custom printing with checkbox (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: