Results 1 to 5 of 5

Thread: VB-Excel: Detect end of extract and print

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2008
    Posts
    46

    Question VB-Excel: Detect end of extract and print

    I am working on some VB script (within Excel) it connects to DB and pulls back information.

    What i need to do it auto-detect the end of the date and seclect it all so that i can run the 'Selection.PrintOut' cmd. Dose anyone know how to detect the end of the data?

    let me explain the data will always be between "A#:J#". The rows could change accoring to the number of records pulled back from the DB.

    Else dose anyone know a better way (aka not using Selection.PrintOut)?

    Thanks for the help guys

    Alien

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB-Excel: Detect end of extract and print

    Quote Originally Posted by alien260 View Post
    I am working on some VB script (within Excel) it connects to DB and pulls back information.
    How does it do that?

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2008
    Posts
    46

    Re: VB-Excel: Detect end of extract and print

    It uses a ADODB.Connection runs some SQL and then prints it to a couple of worksheets.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB-Excel: Detect end of extract and print

    maybe you could use the recordcount of the recordset
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VB-Excel: Detect end of extract and print

    Sheet1.UsedRange.PrintOut
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width