Need help writing a macro to copy a cell formula down a column

Occasional Visitor

I'm an older guy, 70s, who needs help writing an Excel VBA macro. I have a sheet with a standard set of columns, but the rows are variable, anywhere from 250 to 25,000. My goal is to copy an IF statement down a column to the end of the rows of data. I understand that this requires being able to count the number of rows and a loop to copy the IF statement down the column but implementing this is beyond me.  I tried recording and then editing a macro and attempted to include looping but I couldn't get anything to work.


If anyone can suggest an approach or write the code, I'd greatly appreciate it. The purpose of this request is to assist me with analyzing data collected for research my colleagues and I make publicly available on a variety of topics.


Many thanks in advance for considering my request and for any assistance you provide.

1 Reply


Given the information you have provided to date, it is not obvious to me that you do require a VBA macro.  For example, the IF statement would copy down automatically if you were to convert the data range into an Excel Table.


It would be a different situation if you already perform the data analysis using VBA.  Even then, the 'copy down' you describe is a manual process which could be replicated using VBA formulas but could also be better achieved by identifying the range and applying the formula to the entire range as its .formula property as a single step (no copying required).