+ Reply to Thread
Results 1 to 3 of 3

need help connecting the code, Dave Help!!!!

Hybrid View

Guest need help connecting the... 05-27-2005, 07:05 PM
Guest Re: need help connecting the... 05-27-2005, 08:05 PM
Guest Re: need help connecting the... 05-27-2005, 10:05 PM
  1. #1
    RompStar
    Guest

    need help connecting the code, Dave Help!!!!

    Dave :- ), everyone :- )

    Ok, imagine a excel sheet, has columns A to O

    column Names/Headers are at A9:O9

    at A10:O10 raw data...

    So the user enters the dates, this time from column A,

    START DATE

    END DATE,

    I need help to feed that collected data to the last part, see code...
    can anyone help me out.. ? that part of the code works, but I have to
    select with a mouse, I would rather have the user enter the date range
    and then it automatically print it, because there is a lot of ROWS,
    like 3000 and counting...

    Sub PrintRange()

    Dim LastRow As Long
    Dim Rng As Range
    Dim Msg As Integer
    Dim BeginDate As Date
    Dim EndDate As Date
    Dim c As Range
    Dim Item As Range
    LastRow = Range("A10").End(xlDown).Row
    Set Rng = Range("A10" & Range("A65536").End(xlUp).Row)

    Do
    Msg = vbOK
    BeginDate = Application.InputBox("Enter Starting Date from
    column A:", "Range Beginning", Type:=1)
    If Not IsDate(BeginDate) Then

    ' Checks to see if entry is a date

    Msg = MsgBox("Entry not a valid date!", vbCritical +
    vbRetryCancel, "Error: Invalid Date")
    End If
    ' Converts to date format
    BeginDate = DateValue(BeginDate)
    Loop While Msg = vbRetry

    Do
    Msg = vbOK
    EndDate = Application.InputBox("Enter Ending Date from column
    A:", "Range Ending", Type:=1)
    If Not IsDate(EndDate) Then

    Msg = MsgBox("Entry not a valid date!", vbCritical +
    vbRetryCancel, "Error: Invalid Date")
    End If
    EndDate = DateValue(EndDate)

    Loop While Msg = vbRetry


    MsgBox "You selected: " & BeginDate & " through " & EndDate & " ", ,
    "Select Range"

    ' Pass the selected Range to the code below, not sure how yet :- )

    On Error GoTo Finish

    ' --------------------------

    Worksheets("Master").Activate
    Set myRange = Application.InputBox( _
    Prompt:="Select a Range to print!" & Chr(13) & Chr(13) & "Use your
    mouse!" & Chr(13) _
    & "For more than one Range add a ""comma"" between your selected
    Ranges!", Type:=8)
    myRange.Select
    MsgBox "Ready to print: " & Selection.Address
    ActiveSheet.PageSetup.PrintArea = Selection.Address
    ActiveSheet.PageSetup.FitToPagesWide = 1
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("Master").Range("A1").Select

    Finish:

    End Sub


  2. #2
    Dave Peterson
    Guest

    Re: need help connecting the code, Dave Help!!!!

    How about having your macro do a filter on the data.

    You can show rows that are greater than or equal to the begin date and less than
    or equal to the end date.

    Then just print those visible rows.

    Sometimes dates are fussy when working in VBA and autofilter. You may have to
    use the format of the date column in your criteria.

    ===
    You may even just want to teach people to use Data|Autofilter (and custom).
    This is one of the most powerful tools you have in your excel arsenal. And
    it'll be applicable to lots and lots of other workbooks.

    RompStar wrote:
    >
    > Dave :- ), everyone :- )
    >
    > Ok, imagine a excel sheet, has columns A to O
    >
    > column Names/Headers are at A9:O9
    >
    > at A10:O10 raw data...
    >
    > So the user enters the dates, this time from column A,
    >
    > START DATE
    >
    > END DATE,
    >
    > I need help to feed that collected data to the last part, see code...
    > can anyone help me out.. ? that part of the code works, but I have to
    > select with a mouse, I would rather have the user enter the date range
    > and then it automatically print it, because there is a lot of ROWS,
    > like 3000 and counting...
    >
    > Sub PrintRange()
    >
    > Dim LastRow As Long
    > Dim Rng As Range
    > Dim Msg As Integer
    > Dim BeginDate As Date
    > Dim EndDate As Date
    > Dim c As Range
    > Dim Item As Range
    > LastRow = Range("A10").End(xlDown).Row
    > Set Rng = Range("A10" & Range("A65536").End(xlUp).Row)
    >
    > Do
    > Msg = vbOK
    > BeginDate = Application.InputBox("Enter Starting Date from
    > column A:", "Range Beginning", Type:=1)
    > If Not IsDate(BeginDate) Then
    >
    > ' Checks to see if entry is a date
    >
    > Msg = MsgBox("Entry not a valid date!", vbCritical +
    > vbRetryCancel, "Error: Invalid Date")
    > End If
    > ' Converts to date format
    > BeginDate = DateValue(BeginDate)
    > Loop While Msg = vbRetry
    >
    > Do
    > Msg = vbOK
    > EndDate = Application.InputBox("Enter Ending Date from column
    > A:", "Range Ending", Type:=1)
    > If Not IsDate(EndDate) Then
    >
    > Msg = MsgBox("Entry not a valid date!", vbCritical +
    > vbRetryCancel, "Error: Invalid Date")
    > End If
    > EndDate = DateValue(EndDate)
    >
    > Loop While Msg = vbRetry
    >
    > MsgBox "You selected: " & BeginDate & " through " & EndDate & " ", ,
    > "Select Range"
    >
    > ' Pass the selected Range to the code below, not sure how yet :- )
    >
    > On Error GoTo Finish
    >
    > ' --------------------------
    >
    > Worksheets("Master").Activate
    > Set myRange = Application.InputBox( _
    > Prompt:="Select a Range to print!" & Chr(13) & Chr(13) & "Use your
    > mouse!" & Chr(13) _
    > & "For more than one Range add a ""comma"" between your selected
    > Ranges!", Type:=8)
    > myRange.Select
    > MsgBox "Ready to print: " & Selection.Address
    > ActiveSheet.PageSetup.PrintArea = Selection.Address
    > ActiveSheet.PageSetup.FitToPagesWide = 1
    > ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    > Sheets("Master").Range("A1").Select
    >
    > Finish:
    >
    > End Sub


    --

    Dave Peterson

  3. #3
    RompStar
    Guest

    Re: need help connecting the code, Dave Help!!!!

    cool, will look into it, thanks...


+ 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.6.0 RC 1