Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I am a total newbie in programming so this might seem an easy question, still needs an answer though. I am tring to set up macros for certain tasks. I have a list in a sheet with row 1 being the headers, and the data from row 2 to row 100. What I need to do is copy a formula (ie =A2+B2) in column C, from c2 to c100. Because i need to use this macro on other sheets as well that have lets say 150, or 200 rows I need the macro to "understand" and copy the formula only down to where the list ends, (ie the last non-blank cell of column A) Any ideas? Thank you, bay |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
bay,
Select the cell with the formula, then run this macro: Sub FillToMatchColumnA() Dim EndRow As Long EndRow = Range("A65536").End(xlUp).Row ActiveCell.AutoFill Destination:=Range(ActiveCell, _ ActiveCell.Offset(EndRow - ActiveCell.Row, 0)) End Sub HTH, Bernie MS Excel MVP "bay" wrote in message ... Hi I am a total newbie in programming so this might seem an easy question, still needs an answer though. I am tring to set up macros for certain tasks. I have a list in a sheet with row 1 being the headers, and the data from row 2 to row 100. What I need to do is copy a formula (ie =A2+B2) in column C, from c2 to c100. Because i need to use this macro on other sheets as well that have lets say 150, or 200 rows I need the macro to "understand" and copy the formula only down to where the list ends, (ie the last non-blank cell of column A) Any ideas? Thank you, bay |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the formula is not already in C2, then
Sub EstablishFormula() Dim rng as Range set rng = Range(cells(2,1),cells(rows.count,1).End(xlup)) rng.offset(0,2).Formula = "=A2+B2" End Sub -- Regards, Tom Ogilvy "bay" wrote in message ... Hi I am a total newbie in programming so this might seem an easy question, still needs an answer though. I am tring to set up macros for certain tasks. I have a list in a sheet with row 1 being the headers, and the data from row 2 to row 100. What I need to do is copy a formula (ie =A2+B2) in column C, from c2 to c100. Because i need to use this macro on other sheets as well that have lets say 150, or 200 rows I need the macro to "understand" and copy the formula only down to where the list ends, (ie the last non-blank cell of column A) Any ideas? Thank you, bay |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying row formulas to a column? | Excel Worksheet Functions | |||
Copying formulas into column from row information | Excel Discussion (Misc queries) | |||
copying formulas but changing the column # | Excel Discussion (Misc queries) | |||
Copying formulas to end of Column | Excel Discussion (Misc queries) | |||
Copying Formulas From One Column To Another?? | Excel Worksheet Functions |