Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Excel macro Fill down.

$
0
0

All - 

   I am learning to manipulating excel macros within the VBA editor and I am creating a macro that does the following... 

1) insert column (E)

2) label column and add formula in to first cell (E2) 

3) Fill formula down E to bottom of data. Column A is the best reference here as it is the ID field for these rows and will always have data. 

This seems like an obvious concept but I can't get it to work. I can get 1-2 above and fill down using absolute values, but this will be applied to all sorts of workbooks in the future. How do I code: Look at column A for current row, if A is not empty, fill E with formula? 

Or, is there a simpler way to do this? So far, I've found this code (below) but it errors on me every time.  

    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-2]=""Final"",""After"","""")"

Selection.AutoFill Destination:=Range("E2:E" & Range("A65536").End(xlUp).Row)

Can you help? If I'm in the wrong forum, please also let me know. 

Beth


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>