Auto Fill Macro

ctc005

New Member
Joined
Jul 20, 2007
Messages
15
I have never written a macro, but I think I can figure it out with a little help.

What I need to do is I have an area set up in my spreadsheet that has calculations (about 130 rows worth) They can all be dragged manually out to the right to fill in how large I need it. They are broked down by month (i.e. my column headers are months) I want a macro to autofill to the right based on how many years I input into G10. So if I entered 10 I want it to copy (i believe a loop is what its called?) the formulas I have in cells J11 through J130 across to the right for 10 years (120 months). Any help is appreciated. Or if I am being too vague let me know.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,357
Office Version
  1. 365
Platform
  1. Windows
No need for a loop.
Code:
With Range("J1:J130")
    .Copy .Offset(, 1).Resize(, Range("G10") * 12)
End With
 

ctc005

New Member
Joined
Jul 20, 2007
Messages
15
when I run it, it highlights range and tells me

Compile Error:
Invalid or unqualified reference
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,357
Office Version
  1. 365
Platform
  1. Windows
How exactly did you run it?
 

ctc005

New Member
Joined
Jul 20, 2007
Messages
15
copied your code into a new macro and clicked run in the top of my editor screen page
 

ctc005

New Member
Joined
Jul 20, 2007
Messages
15
had a typo, found it and corrected it, it works now, thanks sincerely for your assistance.
 

Forum statistics

Threads
1,181,421
Messages
5,929,805
Members
436,696
Latest member
Mr Rice

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