Help with an autofill macro

markdenovan

Board Regular
Joined
Dec 15, 2002
Messages
97
Hi All,

I have a little problem which I hope someone can help me with.

I use the following formula to work out how long a list is (it's never the same number of rows):

ActiveSheet.UsedRange.Select
irows = Selection.Rows.Count

I then put in a couple of formulas in the columns next to it which works fine.

I then try to autofill using the following code:

Range("C3:E3").Select
Selection.AutoFill Destination:=Range("C3:E(irows)"), Type:=xlFillDefault
Range("C3:E(irows)").Select

I obviously have the wrong syntax, as the macro stops. If I replace the (irows) with the actual row number it works fine.

Can someone please put me straight?

Many thanks,

Mark
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi

Have you tried using this method:

Range("G1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 = "=(RC[-1]-RC[-7])/RC[-1]"
Selection.Copy
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste

Subtitute for your own cell references
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

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