+ Reply to Thread
Results 1 to 8 of 8

VBA on Range

  1. #1
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    VBA on Range

    Hi all,
    The below codes is running the Sub Qry_Run.
    It basically, reads B10 value and output the results to D10

    Please Login or Register  to view this content.

    This is working fine, however, I have many lines, sometimes up to B5000
    How do I modify the code so that it will read the values to the last row of column B and output the results to D10 all the way down?

    Appreciate any help.
    Thank you.
    Last edited by Andrew.Trevayne; 09-18-2017 at 03:18 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA on Range

    I am assuming you use Excel because you mention Range.
    What is Qry_Run?
    I suggest yolu re-read your own question and thisk: "Would somebody reading this understand what I am asking?"
    I don't !
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: VBA on Range

    Qry_Run is another Sub.
    It basically, reads B10 value and output the results to D10

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA on Range

    If that's all it does ... why a sub you could do this with a simple formula unless the sub does moet than that

    in D10:

    Please Login or Register  to view this content.
    Just copy the formula all the way down.

  5. #5
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: VBA on Range

    Thanks but I am not looking for a formula but rather to tweak a working macro.
    If you are interested what it does, here's the rest of the codes.

    Please Login or Register  to view this content.
    It's a macro that queries the Active Directory.
    I need the query to run on all rows in column B not just a single cell.
    Last edited by Andrew.Trevayne; 09-19-2017 at 01:06 AM.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA on Range

    Well this is better than guessing what your Qry_Run did

    Make sure that B10:B200 is the range you want and the loop will process all rows

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: VBA on Range

    Thank you.
    I'm getting a "Method Range of Object" error on line --> Qry_Run c.value, range(c.offset(0,1))
    Any ideas?

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA on Range

    The value that is passed from c seems to be invalid, you'll have to check and see what the content of c.value is

    In the Qry_Run the forst parameter should be a string (according to your code0, so if that is incorrect then it's going through the vba code step-by-step (pressing F8) to start it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 02-24-2017, 02:06 AM
  2. Replies: 4
    Last Post: 07-05-2016, 05:40 AM
  3. Replies: 9
    Last Post: 05-19-2016, 06:48 PM
  4. Replies: 0
    Last Post: 05-18-2016, 04:52 PM
  5. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  6. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  7. send to range, popup box to input what the range should be each time/select range
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2012, 01:37 AM

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