![]() |
Autofill
What I meant, more specifically (sorry I was kind of vague!) , is that have formulas in cells M2 and N2, and I just want them to autofill down For example, if the sheet has 368 rows, I want it to autofill columns and N with the formulas down to the final row. Will that code Dale Preuss Wrote: This assumes that column 1 contains all the rows that need the formula applied to and cell H1 contains the initial formula. Duplicate th copy/paste process for multiple, non-adjacent columns. For adjacent columns, yo could "resize" the copy (".Resize(1, 2)"). Sub procFillFormulas() Cells(1, 8).Copy Range(Cells(2, 8), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 8)).PasteSpecial xlPasteFormulas Application.CutCopyMode = False End Sub Dale Preuss "carg1" wrote: How would I make autofill work in a macro without having t explicitly specify the range of cells I want to fill? I have a sheet in whic the number of rows changes all the time, and I need to autofill equation at the beginning of two columns. -- carg1 ------------------------------------------------------------------------ carg1's Profile http://www.excelforum.com/member.php...o&userid=15271 View this thread http://www.excelforum.com/showthread...hreadid=273174 -- carg ----------------------------------------------------------------------- carg1's Profile: http://www.excelforum.com/member.php...fo&userid=1527 View this thread: http://www.excelforum.com/showthread.php?threadid=27317 |
Autofill
Yes, this code will work; it includes your needed modifications. It is still
assumed that column one contains the last row that should get the formulas. The "End(xlUp)" returns the last row. If a diferent column should be used, change the 1 in "Cells(Rows.Count, 1)" to the desired column number or get your row number using SpecialCells. Sub procFillFormulas() Cells(2, 13).Resize(1, 2).Copy 'copies formulas in cells M2:N2 Range(Cells(3, 13), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 13)).PasteSpecial xlPasteFormulas Application.CutCopyMode = False End Sub Dale Preuss "carg1" wrote: What I meant, more specifically (sorry I was kind of vague!) , is that I have formulas in cells M2 and N2, and I just want them to autofill down. For example, if the sheet has 368 rows, I want it to autofill columns M and N with the formulas down to the final row. Will that code Dale Preuss Wrote: This assumes that column 1 contains all the rows that need the formula applied to and cell H1 contains the initial formula. Duplicate the copy/paste process for multiple, non-adjacent columns. For adjacent columns, you could "resize" the copy (".Resize(1, 2)"). Sub procFillFormulas() Cells(1, 8).Copy Range(Cells(2, 8), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 8)).PasteSpecial xlPasteFormulas Application.CutCopyMode = False End Sub Dale Preuss "carg1" wrote: How would I make autofill work in a macro without having to explicitly specify the range of cells I want to fill? I have a sheet in which the number of rows changes all the time, and I need to autofill equations at the beginning of two columns. -- carg1 ------------------------------------------------------------------------ carg1's Profile: http://www.excelforum.com/member.php...o&userid=15271 View this thread: http://www.excelforum.com/showthread...hreadid=273174 -- carg1 ------------------------------------------------------------------------ carg1's Profile: http://www.excelforum.com/member.php...o&userid=15271 View this thread: http://www.excelforum.com/showthread...hreadid=273174 |
All times are GMT +1. The time now is 10:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com