Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 6 of 6

Thread: Select multiple rows based on variable/IF

  1. #1
    Join Date
    24th August 2004
    Posts
    12

    Select multiple rows based on variable/IF

    I am a relatively skilled user of Excel's included functions, but I have never used macros beyond the basic recorded stage before.

    I am now trying to automate a monthly report that involves comparing two sets of data and eliminating the ones that match in order to separate out discrepancies. In order to do this, I'm trying to compare several cells in a single row with the same cells in the row immediately below. If all data matches, I want to select both rows, move them to a different worksheet, and continue down the list.

    I have hit a snag on selecting multiple rows using the variable of the FOR and IF statements. I am able to select a single row, but not to select both.

    Can anyone offer any (simple if possible - I'm not a programmer so don't get too fancy) suggestions on how to do this?

    Thanks very much in advance

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    11th August 2004
    Location
    Essex, ENGLAND
    Posts
    31
    The following code in an excel macro will select rows 7 and 8 of the active sheet:
    VB:
    Range("7:8").Select 
    
    
    Hope that helps.
    Ian

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    24th August 2004
    Posts
    12

    No luck :(

    Thanks Ian,

    Unfortunately, still not working. I need to be able to select the range based on a variable, and I still get an error when I try to substitute the variable info into the Range() command.

    Using i as a variable, I substituted as follows: Range(i,i+1).Select, trying to get both rows. No go. How can I get the select to accept variable information?

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    25th January 2003
    Location
    UK
    Posts
    2,745
    Hi j,

    Post the code that you are using and somebody will help you to amend it
    Cross-poster? Read this: Cross-posters
    Struggling to use tags (including Code tags)? : Forum tags

  5. #5
    Join Date
    11th August 2004
    Location
    Essex, ENGLAND
    Posts
    31
    You need to change it to:
    VB:
    Range(i & ":" & i+1).Select 
    
    
    Ian

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    24th August 2004
    Posts
    12

    Thank you!

    Perfect - this works exactly!

    Thank you very much!

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Select Rows With Variable Last Row Number
    By Rami33 in forum EXCEL HELP
    Replies: 4
    Last Post: August 16th, 2008, 09:01
  2. Select multiple rows as separate selections
    By SaQ in forum EXCEL HELP
    Replies: 3
    Last Post: August 3rd, 2006, 20:26
  3. Select variable Range based on a user defined number
    By MaulTiper in forum EXCEL HELP
    Replies: 1
    Last Post: April 4th, 2006, 01:48
  4. select range with variable number of rows
    By J88L in forum EXCEL HELP
    Replies: 9
    Last Post: November 26th, 2005, 08:03
  5. select multiple rows with highest value
    By wibbers2000 in forum EXCEL HELP
    Replies: 2
    Last Post: November 5th, 2005, 06:09

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
  •  
porno