J
Jim A
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("D648").
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("D648").Value = _
Range("AR5:AR47").Value
Thanks for your help – Jim Ayers
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("D648").
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("D648").Value = _
Range("AR5:AR47").Value
Thanks for your help – Jim Ayers