Inserting Formula and copying down to last row

jrake40

New Member
Joined
Nov 22, 2016
Messages
30
Hey Guys,

I am inserting the formula but having trouble getting it to copy down. I want it to copy down to the last row of column AA to account for variable data.

Code:
Sub Insert_QueryTitle_Formula()

Range("AA1").Formula = "=IF((LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1),"""",""""))+1)>4,""Title"","""")"
Selection.AutoFill Destination:=Range("AA1:AA" & LastRow)


End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
you have to define LastRow
here is an example
LastRow = ActiveSheet.Range("AA" & Rows.Count).End(xlUp).Row
 
Upvote 0
. I want it to copy down to the last row of column AA to account for variable data.
[/CODE]

If you are stating that there is a filled cell in Column AA that is used to decide the last row (and I have serious doubts that this is the case, and if it is not the case then state what you are using to decide what the last row is), then you can just apply the formula to the range in one go (Excel is intelligent enough to increment the row increases as it goes down the column).

Please see the below...

Code:
Range("AA1:AA" & Range("AA" & Rows.count).End(xlUp).Row).Formula = "=IF((LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1),"""",""""))+1)>4,""Title"","""")"
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
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