+ Reply to Thread
Results 1 to 7 of 7

VBA code to select cells, row by row in range, based on condition

  1. #1
    Spammer
    Join Date
    03-09-2007
    Posts
    8

    Unhappy VBA code to select cells, row by row in range, based on condition

    Hi Excel experts (sorry it was a typo/copy/paste malfunction; you don't need to be so bitter, there r planty of good excel forums to make me not use this one). I haven’t been in the forum for so long, I am sure that I will get help from experts. I am struggling to solve this easy problem but for some reason I cannot make it work. Here is the question and the scenario.

    I have formulas grabbing info from another spreadsheet.
    I have formulas in the range of A1:F20
    The formulas results, if there are info in the respective row on the other sheet, in column A , I get 1, 2 ,3 etc if the B1:F1, B2:F2..Bn:Fn has info. If the next row doesn't have info, the result in cells would be "".

    So for every Cell in my range A1:F20

    if A1 is not "", Highlight yellow A1:F1, Print, Remove Highlight

    next cell

    if A2 is not "", Highlight yellow A2:F2, Print, Remove Highlight

    and so on until it reaches the last row with info, not "".

    The best that I got was that it highlights and prints the whole range, row by row, even if the respective row/cells don't have resulting info, but it prints them because they have formulas.

    Any help greatly appreciated.

    Thank you

    Vera
    Last edited by Vera22; 05-27-2012 at 07:27 AM. Reason: type

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: VBA code to select cells, row by row in range, based on condition

    Quote Originally Posted by Vera22 View Post
    Hi Mr. Excel.
    If you're going to break our rules on cross-posting it's more subtle if you at least call us by the correct name.

    Thread on other forum

  3. #3
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: VBA code to select cells, row by row in range, based on condition

    lol. The above post cracked me up. Sorry, mods, you can delete my post. I just wanted to express that this made my day...
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  4. #4
    Spammer
    Join Date
    03-09-2007
    Posts
    8

    Re: VBA code to select cells, row by row in range, based on condition

    ok, now i am puzzled a bit...am i being "punished" by Cerberus (read ron2k_null/andrew_r) or no expert is available?!?

  5. #5
    Spammer
    Join Date
    03-09-2007
    Posts
    8

    Re: VBA code to select cells, row by row in range, based on condition

    Oh my god Ron, i feel sorry for you if you find such an excitement just from a poor post in a forum; i am wondering if you have a life...lol
    Last edited by Vera22; 05-30-2012 at 02:51 PM.

  6. #6
    Spammer
    Join Date
    03-09-2007
    Posts
    8

    Re: VBA code to select cells, row by row in range, based on condition

    After wasting 3 days arguing to this forum's "volunteers" who only police the users to obey the rules but Excel help null, none, so after being fed up with that, i just put my mind to work and found the solution myself in case that anybody has a similar scenario, you can find the code on the link below:

    My Dear RoyUK

    As I said already, I did not know that I must show the link that I posted in other forum; 5-10 years back when I was attending Excel forums this rule did not exist.
    Regarding this forum, another clue that should have gave me an warning that it is not for me, that it is not friendly, is how difficult you make to use a simple feature such as "search" (i know, spam blah blah, find another way); the user must enter those cryptic words that cannot be read, they are not clear, the user wastes time and after around 5 attempts you can get it right).

    Regarding how concise and clear i presented my question, first of all why anybody did not tell me that you need more details, secondly, if you follow exactly what i said in my intial post, it is very simple to recreat my scenario. Enter on Sheet 1 from A1 an alfa (word), on B1 word, on C1 word, D1 word, E1 word, F1 word , on A2 word and so on to F2 and also same on A3-F3.

    On Sheet 2 on A1 enter formula =if(not(Sheet1A1=""),Sheet1A1,"") and fill this formula on Sheet2 from A1 to F5. I keep it simple; so you get on Sheet2 info from Sheet1 on A1 to F3; on A4 to F5 you get "".

    Now the code should run on Sheet2 and,


    select A1 to F1 (because it has info, because it is not "" in A1),
    fill color (yellow for ex) A1 to F1,
    print (the printing area is already setup to print the whole page),
    change the fill yellow color on A1 to F1 to No Fill

    next row A2 to F2
    select A2 to F2 (because it has info, because it is not "" in A2),
    fill color (yellow for ex) A2 to F2,
    print (the printing area is already setup to print the whole page),
    change the fill yellow color on A2 to F2 to No Fill

    next row A3 to F3
    select A3 to F3 (because it has info, because it is not "" in A3),
    fill color (yellow for ex) A3 to F3,
    print (the printing area is already setup to print the whole page),
    change the fill yellow color on A3 to F3 to No Fill

    The macro should stop after A3 to F3 because A4 is “”

    You know something Roy, you guys annoyed me so much that I looked again over my code and I was able to make it work. I am not going to put it here (not that you care) in your forum because you ARE NOT a forum that cares about users. Anybody interested to see the solution, it should go to Mr. Excel where I posted first my question.

    BTW I looked up and your forum has pages and pages of posts with zero answers, cases more than 5 years old; I guess you have a statistical percentage of posts solved, dare to share? lol i doubt it.


    Thank you and adios.

    because u r so anxious to have a link, here it is
    http://www.mrexcel.com/forum/showthr...=1#post3171283
    Last edited by Vera22; 05-31-2012 at 12:05 PM.

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: VBA code to select cells, row by row in range, based on condition

    Quote Originally Posted by Vera22 View Post
    Thank you and adios.
    Missing you already

+ 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