Formula to be copies from sheet 16 onwards

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have the following formula's on shets16 onwards in Col 1

Code:
 =IF(A25="","",VLOOKUP(A25,'New'!A:AL,COLUMNS($A:AL),FALSE))  

=IF(A100="","",VLOOKUP(A100,'Used'!A:AQ,COLUMNS($A:AQ),FALSE))


I would like a macro to insert the first formula in Col I row 25 and copy this up to row 98 from sheet16 to the last sheet


I would like a macro to insert the first formula in Col I in row 100 and copy this up to row 200 from sheet16 to the last sheet


Your assistance is most appreciated
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
=IF(A25="","",VLOOKUP(A25,'New'!A:AL,COLUMNS($A:AL),FALSE))
I would like a macro to insert the formula in Col I row 25 and copy this up to row 98 from sheet16 to the last sheet

- test in a COPY of your workbook

Code:
Sub AddFormula()
    Dim aFormula As String, Rng As Range, Ws As Worksheet, x As Long
    aFormula = "=IF(A25="""","""",VLOOKUP(A25,'New'!A:AL,COLUMNS($A:AL),FALSE))"
'place formula in sheet16
    Set Rng = ThisWorkbook.Sheets("Sheet16").Range("I25")
    Rng.Formula = aFormula
'place formula in other sheets
    For x = Sheets("Sheet16").Index To ThisWorkbook.Worksheets.Count
        Sheets(x).Range("I25").Resize(74) = Rng.Formula
    Next
End Sub

=IF(A100="","",VLOOKUP(A100,'Used'!A:AQ,COLUMNS($A:AQ),FALSE))
I would like a macro to insert the formula in Col I in row 100 and copy this up to row 200 from sheet16 to the last sheet

- modify the above to match your 2nd formula and range
 
Last edited:
Upvote 0
note that I amended the above after initial posting to simplify the code
 
Upvote 0
Thanks for the help. code works perfectly. I will set up the code for the second formula
 
Upvote 0
The variable Ws is no longer being used in the code - it can be removed from declarations in first line

Thanks for the feedback :beerchug:
 
Upvote 0
thanks for letting me know. I have made the changes for the second formula in the code and it works perfectly
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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