Results 1 to 2 of 2

Vba code assistance to print rows based on column date value

Threaded View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Vba code assistance to print rows based on column date value

    Hi All

    I need assistance with the following code I have put together from pieces found. I have attached my file. I would want the code to find the specific rows with the date value and only print those rows. Please help have been trying to figure it out for hours.

    Sub Print_Date()
         
    Dim rng1 As Range
    Dim dateStr As String
    Dim dateToFind As Date
    Dim foundDate As Range
    
    'Get date as string value
    dateStr = InputBox("Enter the date to be found")
    
    'Convert string value to date format
    dateToFind = DateValue(dateStr)
    'Edit Sheet1 to your worksheet name
    Set rng1 = Sheets("Payment transactional history").Range(Cells(1, 9), _
    Cells(Rows.Count, 9).End(xlUp))
    
    Set foundDate = rng1.Find(What:=dateToFind, _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False, _
    SearchFormat:=False)
    
    If Not foundDate Is Nothing Then
    Application.Goto rng1, True
    ActiveSheet.PageSetup.PrintArea = Range("b:j").End(xlUp)
    Selection.AutoFilter Field:=1, Criteria1:=dateToFind
                      With ActiveSheet
                        .PrintPreview
                       
                        End With
    
    Else
    MsgBox dateStr & " not found"
    End If
    
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Is This Possible? Color Code a Date Column Based on Value/No Value in Another Column
    By noodlenoodle in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-19-2014, 09:05 AM
  2. Replies: 5
    Last Post: 08-01-2014, 04:30 PM
  3. Replies: 10
    Last Post: 11-13-2013, 09:01 PM
  4. VBA code to print rows based on value in select column
    By deadeyesky in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2013, 10:50 AM
  5. [SOLVED] Formula assistance needed to sum data based on anniversary date and month date
    By lilsnoop in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-28-2012, 11:18 PM
  6. Code to delete rows based on status code in Column I
    By LemonTwist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2009, 07:01 PM
  7. [SOLVED] Auto Fill Column with Date based on rows in other column
    By JOUIOUI in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2006, 01:35 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