VBA macro to fill down, I'm lost!

neuro1

New Member
Joined
Sep 9, 2022
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
  2. Web
Hi, I need some help with writing a macro I can run to do the following:

I have an excel workbook with 14 sheets, each sheet has 20 columns. Each column has a different formula on cell A4 that I need to fill down until A254. How would I make a macro to automate this process of filling down formulas ( so sheet 1 -> formula in A2, I need to fill down to A254 and then go to B2 and so on until T2 then go to sheet2 and do the same)?

Maybe I can make a macro and just rerun it different sheets?

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Each column has a different formula on cell A4 that ....so sheet 1 -> formula in A2,
  1. Are the first formulas in row 4 or row 2? It is unclear above.

  2. Are the formulas already in row 4 (or row 2) of one or all sheets or does the code need to put them in right from the start?

  3. Are the 14 sheets to get formulas the only sheets in the workbook? If not, how do we know which 14 sheet to put the formulas in?

  4. Is it always to row 254? If not, how do we work out how far down to put the formulas?

  5. Are the formulas exactly the same in each sheet?

  6. Can you give us examples of a few of the actual formulas? Say for columns A, B, C and D?
 
Upvote 0
Hi, I need some help with writing a macro I can run to do the following:

I have an excel workbook with 14 sheets, each sheet has 20 columns. Each column has a different formula on cell A4 that I need to fill down until A254. How would I make a macro to automate this process of filling down formulas ( so sheet 1 -> formula in A2, I need to fill down to A254 and then go to B2 and so on until T2 then go to sheet2 and do the same)?

Maybe I can make a macro and just rerun it different sheets?

Thanks
Show me an example of the formula you want filled down.
 
Upvote 0
Show me an example of the formula you want filled down.
  1. Are the first formulas in row 4 or row 2? It is unclear above.

  2. Are the formulas already in row 4 (or row 2) of one or all sheets or does the code need to put them in right from the start?

  3. Are the 14 sheets to get formulas the only sheets in the workbook? If not, how do we know which 14 sheet to put the formulas in?

  4. Is it always to row 254? If not, how do we work out how far down to put the formulas?

  5. Are the formulas exactly the same in each sheet?

  6. Can you give us examples of a few of the actual formulas? Say for columns A, B, C and D?
  1. Are the first formulas in row 4 or row 2? It is unclear above. row 2

  2. Are the formulas already in row 4 (or row 2) of one or all sheets or does the code need to put them in right from the start? they are already in row 2 in all the sheet

  3. Are the 14 sheets to get formulas the only sheets in the workbook? If not, how do we know which 14 sheet to put the formulas in? there are only 14 sheets (this never changes)

  4. Is it always to row 254? If not, how do we work out how far down to put the formulas? yes

  5. Are the formulas exactly the same in each sheet? no, they are different for each column in sheet

  6. Can you give us examples of a few of the actual formulas? Say for columns A, B, C and D? the first 3 columns are point to data in sheet 1 and below is the type of forumla that is found in columns G to P.
 

Attachments

  • Screenshot 2024-01-22 084927.png
    Screenshot 2024-01-22 084927.png
    13.9 KB · Views: 8
Upvote 0
Thanks for the responses. Try this with a copy of your workbook.

VBA Code:
Sub Fill_Formulas()
  Dim ws As Worksheet
  
  For Each ws In Worksheets
    ws.Range("A2:T256").FillDown
  Next ws
End Sub
 
Upvote 0
Thanks for the responses. Try this with a copy of your workbook.

VBA Code:
Sub Fill_Formulas()
  Dim ws As Worksheet
 
  For Each ws In Worksheets
    ws.Range("A2:T256").FillDown
  Next ws
End Sub
Is it possible to modify the code so that I only fill down in sheets 2-15 and skip sheet 1? Also would I put this code in module, correct?
 
Upvote 0
Is it possible to modify the code so that I only fill down in sheets 2-15 and skip sheet 1?
That why I asked this earlier ;)
Are the 14 sheets to get formulas the only sheets in the workbook? If not, how do we know which 14 sheet to put the formulas in?

Try this version
VBA Code:
Sub Fill_Formulas_v2()
  Dim i As Long
 
  For i = 2 To 15
    Sheets(i).Range("A2:T256").FillDown
  Next i
End Sub

The code goes in a standard module, typically 'Module1'
1706057152914.png
 
Upvote 0
That why I asked this earlier ;)


Try this version
VBA Code:
Sub Fill_Formulas_v2()
  Dim i As Long
 
  For i = 2 To 15
    Sheets(i).Range("A2:T256").FillDown
  Next i
End Sub

The code goes in a standard module, typically 'Module1'
View attachment 105605
This works great except I have an issue on one of the pages, where after I inserted a row, I get '#REF' even after I run the module. (see the picture).
 

Attachments

  • Screenshot 2024-01-24 114047.png
    Screenshot 2024-01-24 114047.png
    15.1 KB · Views: 3
Upvote 0
We cannot tell anything about that from a picture. Presumably it is a problem with the original formula that is being copied down.
Can you post a small section of the problem sheet with XL2BB?
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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