Fill formulas down a column

kramart

New Member
Joined
Apr 3, 2014
Messages
39
Hi,

I have this code to insert my formula and fill down the column.


wsFirst.Range("AQ3:AQ" & Cells(Rows.Count, 1).End(xlUp).Row).Formula = "=IF(P19=1,1,0)"

The problem is that it stops at 101'st row. I think this is related to the fact that before i created the range "ipi" with 101 values. How to amend this line so it runs until the last row with value in column A in the first sheet.?


This is a part of my whole VBA code

'Add new sheet
Set ws = Worksheets.Add(After:=Sheets(Worksheets.Count))

'Name sheet
ws.Name = "ref1"

'Paste results into new sheet
Range("A1:A101") = WorksheetFunction.Transpose(result())

'Name cell range
Range("A1:A101").Name = "ipi"

'set variable to first sheet in workbook
Set wsFirst = Worksheets(1)

'insert row
wsFirst.Rows(1).Insert

'Set headings on AA1,AB1 & AC1

wsFirst.Range("AQ2:AS2") = Array("One", "Two", "Three")

'insert formulas

wsFirst.Range("AQ3:AQ" & Cells(Rows.Count, 1).End(xlUp).Row).Formula = "=IF(P19=1,1,0)"
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
wsFirst.Range("AQ3:AQ" & Cells(Rows.Count, 1).End(xlUp).Row).Formula = "=IF(P19=1,1,0)"
Code:
wsFirst.Range("AQ3:AQ" & Cells([COLOR=#ff0000]1048576[/COLOR], 1).End(xlUp).Row).Formula = "=IF(P19=1,1,0)"
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,387
Members
449,080
Latest member
Armadillos

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