+ Reply to Thread
Results 1 to 2 of 2

Macro to print selected(ticked) ticked rows.

Hybrid View

emymeeky Macro to print... 06-06-2014, 03:08 AM
jaslake Re: Macro to print... 06-08-2014, 04:13 PM
  1. #1
    Registered User
    Join Date
    12-14-2013
    Location
    edo,nigeria
    MS-Off Ver
    Excel 2007
    Posts
    85

    Macro to print selected(ticked) ticked rows.

    I have different tabs in a workbook. I have already created a macro that sorts the data in each tab(based on selection) and transfers the sorted tab to a new tab named "subject". Now , this tab contains the sorted data from the selected tab. I would want to be able to tick some rows in this subject tab and have those rows copied to another sheet for printing. This new sheet will still maintain the same heading as the subject row. The sample is attached below.
    In summary, I have a print button,when a tab( which needs sorting) is selected, it does the sorting and automatically takes you to the "subject" tab. Now I want some rows to be printed from this tab by selecting a tick box on each row. Now ,these rows are transferred to a new sheet while maintaining the original headings from the subject tab where the final printing is done. The rows could be many and might require many tick boxes(I don't really know how this will be achieved but you know better.
    An example will be shown in the attached file. Hope Am clear enough.
    If this is achieved, I will be the happiest man on earth!
    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to print selected(ticked) ticked rows.

    Hi emymeeky

    I've gotta admit I don't understand your "Go" Button Code.

    The Code copies Sheet "answer" to Sheet "separate" then Sheet "separate" is copied to Sheet6 then Sheet6 is copied to Sheet2 and finally Sheet2 is copied to Sheet "Subject". It seems to me this could be greatly simplified to eliminate a lot of the "middle men".

    However, you indicate it works for you so I've not changed the Code except to add this line at the very top
    Private Sub CommandButton1_Click()
      Dim answer As String
      answer = Cmbtablist.Value
    
      Application.ScreenUpdating = False  '<---Added this line
    and these lines at the very bottom
     Range("B7").Select
      Call add_CBX                      '<---added this line
      Application.ScreenUpdating = True '<---added this line
      Unload Me
    End Sub
    The Code that does the work for the Checkboxes is in Modules 5 and 6.

    Module 5
    Option Explicit
    
    Sub add_CBX()
      Dim myCBX As CheckBox
      Dim myCell As Range
      With ActiveSheet
        Call Delete_All_CBX
        For Each myCell In ActiveSheet.Range("A7:A" & Range("B" & Rows.Count).End(xlUp).Row)
          With myCell
            Set myCBX = .Parent.CheckBoxes.Add _
                        (Top:=.Top + 1, Width:=.Width, _
                         Left:=.Left, Height:=.Height)
            With myCBX
              .Caption = ""
            End With
          End With
        Next myCell
      End With
    End Sub
    
    
    Sub Clear_All_CBX()
      Dim CB As CheckBox
    
      For Each CB In ActiveSheet.CheckBoxes
        CB.Value = False
      Next CB
    End Sub
    
    
    Sub Delete_All_CBX()
      ActiveSheet.CheckBoxes.Delete
    End Sub
    Module 6
    Option Explicit
    
    Sub Button1368_Click()
      Dim LR As Long
      Dim ws As Worksheet
      Dim CB As CheckBox
    
      Application.ScreenUpdating = False
      Set ws = Sheets("final")
      With ws
        LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                         SearchDirection:=xlPrevious).Row
        If LR = 13 Then
          LR = 15
        End If
        .Range("B15:M" & LR).Clear
        LR = 15
    
        For Each CB In ActiveSheet.CheckBoxes
          If CB.Value = 1 Then
            Range("B" & CB.TopLeftCell.Row & ":M" & CB.TopLeftCell.Row).Copy
            ws.Range("B" & LR).PasteSpecial
            LR = LR + 1
          End If
        Next CB
      End With
      Call Clear_All_CBX
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
    End Sub
    Try it...see if it does as you require.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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. Replies: 12
    Last Post: 05-14-2014, 05:49 AM
  2. [SOLVED] Print in new page all ticked box
    By traga2whiskys in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2012, 05:01 PM
  3. If Checkbox is Ticked and Cell has Value then Run Macro
    By Heavenkissing in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2011, 10:34 AM
  4. Add value when checkbox is ticked
    By emel24 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-29-2006, 05:21 AM
  5. Delete rows with ticked checkbox
    By Sibilia in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2005, 08:21 AM

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