+ Reply to Thread
Results 1 to 11 of 11

Excel userform - print using a date range

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Excel userform - print using a date range

    I have frmInventory which has a command button "PRINT", I need help with code to make that button request a date range and then only print the records in that date range. Example print records starting from date range 01/01/2013 to 04/16/2013.

    Please see attachment, Thank you!
    Attached Files Attached Files
    Last edited by PANTECH; 04-17-2013 at 04:00 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel userform - print using a data range

    See the attached file.
    Attached Files Attached Files
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel userform - print using a data range

    The drop down worked for the date range but it did not print. Please advise as to what is missing to make the rows print.

    Thank you!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel userform - print using a data range

    I commented out the line of code that actually prints as I don't want to end up with a bunch of print outs I don't want.

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel userform - print using a data range

    Keep getting error '424' object required.
    Problem area
    Set rngPrintArea = .Range("A" & ComboBox1.ListIndex + 2, .Range("I" & ComboBox2.ListIndex + ComboBox1.ListIndex + 2))
    Should I change ComboBox1 etc to the actual names cboDepartment and cboInitials?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel userform - print using a data range

    Are you using the file I uploaded?

  7. #7
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel userform - print using a data range

    No, I can't we are restricted from downloading so I did a cut and paste from your Print form into my frmInventory.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel userform - print using a data range

    Did you copy the form I added?

    The code you say is erroring is intended for that form.

  9. #9
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel userform - print using a data range

    Yes, I copied your form and still get the same error. Should I change ComboBox1 etc to the actual names cboDepartment and cboInitials?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Excel userform - print using a data range

    There are no controls with those names on the form in the workbook I posted.

    Where did you put the code you copied?

    The easiest way to copy a userform, and it's code, to another workbook is to open the workbook with the form and
    in the Project Explorer drag the form to the workbook you want to copy it to.

  11. #11
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel userform - print using a data range

    The working userform is on the network drive which I don't have rights to copy to so I have a backup on my H: drive which is where your frmPrint is located. Below is where the problem seemd to be when I debug.
    Set rngPrintArea = .Range("A" & ComboBox1.ListIndex + 2, .Range("I" & ComboBox2.ListIndex + ComboBox1.ListIndex + 2))
    What if I change this to...
    Set rngPrintArea = .Range("A" & CboDepartment.ListIndex + 2, .Range("I" & CboInitials.ListIndex + ComboBox1.ListIndex + 2))

+ 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