+ Reply to Thread
Results 1 to 3 of 3

Thread: Help- Need to create macro that prints only certain data

  1. #1
    Registered User
    Join Date
    02-10-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    1

    Help- Need to create macro that prints only certain data

    I have a worksheet that tracks data for the year, but I only want to print out data for a current date. How can I do this? For example, my spreadsheets tracks demand for products for a year, and I want to create a button that says "print" but only prints out data for the current date. The spreadsheet will show the entire year of dates in the columns.

    Any suggestions on how to print just the current date of informaton? THANKS!
    Bagley

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,386

    Re: Help- Need to create macro that prints only certain data

    You can filter out for the current date and then execute the print command on the filtered data. This can be done manually or if its too time-consuming / tedious, have a macro do it for you.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Valued Forum Contributor JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    779

    Re: Help- Need to create macro that prints only certain data

    Try this,
    Click the button.
    Enter the date between 2012/1/1 to 2012/7/22 and see if it does what you want.
    Sub d()
    
      Dim x, c01, c03&, col, LC&
      Dim ws As Worksheet
      
       Application.ScreenUpdating = 0
      
        Set ws = Sheets("Sheet2")
        
             x = ws.Cells(1).CurrentRegion
            
                  c02 = InputBox("Please enter the date you need the column copied for.", "Date")
                  c02 = DateSerial(Year(c02), Month(c02), Day(c02))
          On Error GoTo 0
            For i = 1 To UBound(x, 2)
             Set c01 = ws.Columns(i).Find(c02, , xlValues, xlWhole)
                If Not c01 Is Nothing Then
                  With ws
                     .Cells(1, 7).Resize(UBound(x)).Value = .Cells(1, i).Resize(UBound(x)).Value
                    .PageSetup.PrintArea = Cells(1, 7).CurrentRegion.Address
                     Exit Sub
                  End With
                End If
            Next i
       Application.ScreenUpdating = 1
    End Sub
    Attached Files Attached Files
    Last edited by JapanDave; 02-11-2012 at 04:30 AM.
    If you are happy with the answer, please click the Star icon in the below left hand corner.

    Good sites to start learning.

    snb's VBA Help Files
    Jerry Beaucaires Excel Assistant
    J & R Excel Consultancy Services

    How to post code correctly: Correct Code Posting

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0