how to use If function in excel using vba on entire column

m_vishal_c

Board Regular
Joined
Dec 7, 2016
Messages
209
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
hi Everyone
i have one excel workbook. The column structure is as below
AY AZ BB
date date -------

there are more then 4000 records(rows) in AY and AZ column. I need if function like if(AZ>=AY,"",AY) through vba. this formula will be placed on BB column

is anybody help me out

heaps thanks in advance

thanks
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Why not just copy the formula down as needed? dragging down 4000 rows should take seconds
 
Upvote 0
Why not just copy the formula down as needed? dragging down 4000 rows should take seconds
hi Thanks for reply. this is not only one formula i have to place this formula in vba long code. there are such more formulas. i can do it manually but i want to update by vba not manually
 
Upvote 0
Maybe

Code:
Range("BB2:BB" & Cells(Rows.Count, "AZ").End(xlUp).Row).Formula = "=IF(AZ2>AY2,"""",AY2)"

Assumes data begin in row 2

M.
 
Last edited:
Upvote 0
Maybe

Code:
Range("BB2:BB" & Cells(Rows.Count, "AZ").End(xlUp).Row).Formula = "=IF(AZ2>AY2,"""",AY2)"

Assumes data begin in row 2

M.

hi Marcelo Branco. thanks for replying. i think this will work only row no 2 . i need to for entire column. i have 4000 rows
 
Upvote 0
hi Marcelo Branco. thanks for replying. i think this will work only row no 2 . i need to for entire column. i have 4000 rows

No, no, it works for all rows in the range BB2:BBx where x is the last row with data. Have you tried?

M.
 
Upvote 0
No, no, it works for all rows in the range BB2:BBx where x is the last row with data. Have you tried?

M.

hi, i tried but it gives me this error " Run time error 1004; Application - defined or object - defined error

Please guide me
thanks
 
Upvote 0
hi Marcelo Branco, sorry my bad, it works. so sorry for that. heaps thanks
 
Upvote 0
Great it worked!

M.
hi Marcelo Branco. Thanks for resolving my query. Actually I wanted to count only " not blank " cells in column that's why I needed that formula . it works but when I place below formula then It counts all. I need formula which count only " Not blank " cells in same column

=COUNTIFS(ABC!$B:$B,A5,ABC!$BB:$BB,"<>")

we placed your formula on BB column but when I place above formula to get "Not Blank" cell on BB column, it gives me wrong result . can you help me to find out only "Not Blank " cells in same column

heaps thanks
 
Upvote 0

Forum statistics

Threads
1,215,030
Messages
6,122,762
Members
449,095
Latest member
m_smith_solihull

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