Announcement

Collapse
No announcement yet.

Select multiple rows based on variable/IF

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    The following code in an excel macro will select rows 7 and 8 of the active sheet:
    Code:
    Range("7:8").Select
    Hope that helps.
    Ian
    Hope that helps
    Ian Eldred
    Fantasy Formula 1 : http://www.fantasyformula1.uni.cc

    Comment


    • #3
      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?

      Comment


      • #4
        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

        Comment


        • #5
          You need to change it to:
          Code:
          Range(i & ":" & i+1).Select
          Ian
          Hope that helps
          Ian Eldred
          Fantasy Formula 1 : http://www.fantasyformula1.uni.cc

          Comment


          • #6
            Thank you!

            Perfect - this works exactly!

            Thank you very much!

            Comment

            Working...
            X