+ Reply to Thread
Results 1 to 1 of 1

Macro to check range, if false check another range until true, then copy

Hybrid View

jayers Macro to check range, if... 01-12-2009, 04:19 PM
  1. #1
    Registered User
    Join Date
    12-31-2008
    Location
    Chester, CA
    MS-Off Ver
    Excel 2007
    Posts
    20

    Macro to check range, if false check another range until true, then copy

    Hi – I have been trying to work out a macro.
    I am looking for a macro that will check 2 things....then do something.
    The first is if a particular cell contains a given value. Lets say
    Sheets("sheet1").Range("D3")
    should equal "Year 1" if true.

    Next is if a range of cell values in are blank,
    Sheets("Sheet1").Range("D6:G48")
    should be blank.
    If both these are true then I want the macro to copy a range of cells from
    Sheets("Sheet2").Range("AR5:AR47")
    to
    Sheets("Sheet1").Range("D6:D48")
    .
    If false then move on to the next range of cells (go on to “Year 2” and its corresponding range of cells) and perform this same check until True.

    Conditions are:
    -I have five distinct ranges of cells starting with "Year 1" going through "Year 5" on Sheet1.
    -
    Sheets("Sheet1").Range("D6:G48")
    only belongs to Year 1. The label “Year 1” is in cell D3.
    -
    Sheets("Sheet1").Range(""I6:L48")
    belongs to Year 2. The label “Year 2” is in cell I3.
    -And so on...through Year 5.
    -I have the Years listed in a combo box on Sheet2 (where I also have a button that activates this macro).
    I have tried this code, BUT I can NOT get the macro beyond simply looking at “Year 1.” I am to unfamiliar with Looping and Next to make it work here.
    If WorksheetFunction.CountA(Sheets("Credit History").Range("D6:G48")) = 0 _
    And UCase(Sheets("Credit History").Range("D3")) = UCase("Year 1") Then
    Sheets("Credit History").Range("D6:D48").Value = _
    Range("AR5:AR47").Value
    Thanks for your help – Jim Ayers
    Attached Files Attached Files
    Last edited by jayers; 01-26-2009 at 11:54 PM. Reason: Added all code tags

+ 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