Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to write in my macro to put a specific formula in cell C2 then
copy it to all cells in that column that are active rows. The active rows will change each time, so I may have 50 then 25. I then need to copy that column and do a paste special values to get rid of the formula and just have the value. Here is the code, but it is not working. Please help! Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[2]0,400,500)" Selection.Copy lastrow = Cells(Rows.Count, "c").End(xlUp).Row ActiveSheet.PasteSpecial Paste:=xlPasteValues |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
LastRow = Cells(Rows.Count, "c").End(xlUp).Row
Range("C2").Resize(LastRow - 1).FormulaR1C1 = "=IF(RC[2]0,400,500)" -- HTH RP (remove nothere from the email address if mailing direct) "Jasmine" wrote in message ... I am trying to write in my macro to put a specific formula in cell C2 then copy it to all cells in that column that are active rows. The active rows will change each time, so I may have 50 then 25. I then need to copy that column and do a paste special values to get rid of the formula and just have the value. Here is the code, but it is not working. Please help! Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[2]0,400,500)" Selection.Copy lastrow = Cells(Rows.Count, "c").End(xlUp).Row ActiveSheet.PasteSpecial Paste:=xlPasteValues |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am getting a Run-time error 1004.
"Bob Phillips" wrote: LastRow = Cells(Rows.Count, "c").End(xlUp).Row Range("C2").Resize(LastRow - 1).FormulaR1C1 = "=IF(RC[2]0,400,500)" -- HTH RP (remove nothere from the email address if mailing direct) "Jasmine" wrote in message ... I am trying to write in my macro to put a specific formula in cell C2 then copy it to all cells in that column that are active rows. The active rows will change each time, so I may have 50 then 25. I then need to copy that column and do a paste special values to get rid of the formula and just have the value. Here is the code, but it is not working. Please help! Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[2]0,400,500)" Selection.Copy lastrow = Cells(Rows.Count, "c").End(xlUp).Row ActiveSheet.PasteSpecial Paste:=xlPasteValues |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you have anything in column C?
If not, then LastRow will be 1 and lastrow -1 will be 0. Can you use a different column than C to get the lastrow... Maybe B: LastRow = Cells(Rows.Count, "B").End(xlUp).Row Jasmine wrote: I am getting a Run-time error 1004. "Bob Phillips" wrote: LastRow = Cells(Rows.Count, "c").End(xlUp).Row Range("C2").Resize(LastRow - 1).FormulaR1C1 = "=IF(RC[2]0,400,500)" -- HTH RP (remove nothere from the email address if mailing direct) "Jasmine" wrote in message ... I am trying to write in my macro to put a specific formula in cell C2 then copy it to all cells in that column that are active rows. The active rows will change each time, so I may have 50 then 25. I then need to copy that column and do a paste special values to get rid of the formula and just have the value. Here is the code, but it is not working. Please help! Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[2]0,400,500)" Selection.Copy lastrow = Cells(Rows.Count, "c").End(xlUp).Row ActiveSheet.PasteSpecial Paste:=xlPasteValues -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That worked! Thanks!
"Dave Peterson" wrote: Do you have anything in column C? If not, then LastRow will be 1 and lastrow -1 will be 0. Can you use a different column than C to get the lastrow... Maybe B: LastRow = Cells(Rows.Count, "B").End(xlUp).Row Jasmine wrote: I am getting a Run-time error 1004. "Bob Phillips" wrote: LastRow = Cells(Rows.Count, "c").End(xlUp).Row Range("C2").Resize(LastRow - 1).FormulaR1C1 = "=IF(RC[2]0,400,500)" -- HTH RP (remove nothere from the email address if mailing direct) "Jasmine" wrote in message ... I am trying to write in my macro to put a specific formula in cell C2 then copy it to all cells in that column that are active rows. The active rows will change each time, so I may have 50 then 25. I then need to copy that column and do a paste special values to get rid of the formula and just have the value. Here is the code, but it is not working. Please help! Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[2]0,400,500)" Selection.Copy lastrow = Cells(Rows.Count, "c").End(xlUp).Row ActiveSheet.PasteSpecial Paste:=xlPasteValues -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can't Copy and Paste or Paste Special between Excel Workbooks | Excel Discussion (Misc queries) | |||
Paste and Paste Special No Longer Working - Excel 2003 | Excel Discussion (Misc queries) | |||
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. | Excel Worksheet Functions | |||
How do I capture user paste action and convert to Paste Special | Excel Programming | |||
Dynamic Copy/Paste Special Formulas/Paste Special Values | Excel Programming |