Applying a formula down a column, only as far as needed

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
235
Office Version
  1. 365
Hi.

My table length will vary week to week. I want to put data in column A, only if there is data on the same row in column F.

My macro at the moment is...

Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=IF(iserror(VLOOKUP(RC[5],Sheet1!C,1,FALSE)),""yes"",""no"")"

Columns("A:A").Select
Selection.FillDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "tp"
Range("A7").Select


But this is populating the data in the whole of column A, how do I fix?
 
Really appreciate your help, but still no joy. Now I get a run time error 1004, range of object global failed with these two rows highlighted when I click debug ...
I'll get it right eventually (honest) :)
It should be
Code:
Range("A2:A"[COLOR=#ff0000] &[/COLOR] Range("F" & Rows.Count).End(xlUp).Row).FormulaR1C1 = _
   "=IF(iserror(VLOOKUP(RC[5],sheet1!C,1,FALSE)),""yes"",""no"")"
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You said in your original post:
My table length will vary week to week. I want to put data in column A, only if there is data on the same row in column F.

A Table and a sheet are not the same.

A Table is a certain range on a Sheet.
Not sure what version of Excel your using.

But on most never versions even as far back as 2013 you can insert on your sheet a Table.
On Your ribbon you should see Insert Table.

So if you are not using a Table you should say my sheet column A length changes.

my sheet column A length changes
 
Upvote 0
I'll get it right eventually (honest) :)
It should be
Code:
Range("A2:A"[COLOR=#ff0000] &[/COLOR] Range("F" & Rows.Count).End(xlUp).Row).FormulaR1C1 = _
   "=IF(iserror(VLOOKUP(RC[5],sheet1!C,1,FALSE)),""yes"",""no"")"

Perfect - thank you so much!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
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