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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Not sure, but something like this?
Code:
    With Sheets("Resource%PerWeek").Range("C3:BA1119")
         .Value = .Value
    End With
 

BenjaminDubai

New Member
Joined
May 7, 2007
Messages
42
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 ??
 

Forum statistics

Threads
1,181,102
Messages
5,928,067
Members
436,586
Latest member
latintxn

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
Top