Simple Loop - To save me typing 50 times!

BenjaminDubai

New Member
Joined
May 7, 2007
Messages
42
What I would like to do is repeat the below formula changing 2 things 50 times.

What I want to change is highlighted.

'Add formaula to cell

Sheets("Resources").Select
Range("A3").Select
ActiveCell.FormulaR1C1 = _
"=AND('Resource%PerWeek'!RC2=Resources!R1C,Dates!RC1=TRUE)"

'Autofill the page
Application.Run "'Resource%Calculator.xls'!AutofillArea"

'Select the range that is now correct, copy and paste values

Sheets("Resource%PerWeek").Select
Range("C3:C1119").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False


I would like the column to move from 1 to 2, to 3, etc... until 50.

I would like the range to move from C3:C1119 to D3:D1119 to E3:E1119 etc until it hits AZ3:AZ1119

Can you help?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Not sure, but something like this?
Code:
    With Sheets("Resource%PerWeek").Range("C3:BA1119")
         .Value = .Value
    End With
 
Upvote 0
Thank you -- but this turns my cells into values not formulas - it does it in a nicer way that I knew - great.

But this does not help me with what I need.

I need to add a formula

ActiveCell.FormulaR1C1 = _
"=AND('Resource%PerWeek'!RC2=Resources!R1C,Dates!RC1=TRUE)"

to a region. Once this is in place then the first column ("C:C") of another workbook contains the correct figures. Hence then I want to .Value them.

After I have done that I want to change formula in the area to be based on a new date. The next date is in Dates!R1C2. Hence:


ActiveCell.FormulaR1C1 = _
"=AND('Resource%PerWeek'!RC2=Resources!R1C,Dates!RC2=TRUE)"

then i autofill the region. Once it is autofilled then column 2 ("D:D") of my workbook contains the figures that I want. So I .Value them.

I want to do this 50 times. Can I do something like

Let x = 1 to 50 and y = C to AZ

and put in X's and y's so that this code repeats ??
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top