Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a macro that contains the following code:
Range("R2").Select ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").Select Selection.AutoFill Destination:=Range("R2:R1006") What I am doing is simply creating a formula in cell R2 (it will always be in R2) and then auto filling to the last populated row. I am struggling on how to change the part of the code that says "Range("R2:R1006")". Every time this macro runs the number of rows will not be 1006. How is it that I change this? TIA John |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Depends how you determine 1006. Lets assume it is the last populated row in
column Q. The you can do it kinda like this... Range("R2").FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").AutoFill Destination:=Range("R2", _ Cells(Rows.Count, "Q").End(xlUp).Offset(0, 1)) -- HTH... Jim Thomlinson "runsrealfast" wrote: I have a macro that contains the following code: Range("R2").Select ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").Select Selection.AutoFill Destination:=Range("R2:R1006") What I am doing is simply creating a formula in cell R2 (it will always be in R2) and then auto filling to the last populated row. I am struggling on how to change the part of the code that says "Range("R2:R1006")". Every time this macro runs the number of rows will not be 1006. How is it that I change this? TIA John |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
NumRows = 1006
Range("R2").FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").AutoFill Destination:=Range("R2:R" & NumRows) -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "runsrealfast" wrote in message oups.com... I have a macro that contains the following code: Range("R2").Select ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").Select Selection.AutoFill Destination:=Range("R2:R1006") What I am doing is simply creating a formula in cell R2 (it will always be in R2) and then auto filling to the last populated row. I am struggling on how to change the part of the code that says "Range("R2:R1006")". Every time this macro runs the number of rows will not be 1006. How is it that I change this? TIA John |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Jul 16, 2:56 pm, "Bob Phillips" wrote:
NumRows = 1006 Range("R2").FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").AutoFill Destination:=Range("R2:R" & NumRows) I think this is what I was looking for |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Jul 16, 2:56 pm, "Bob Phillips" wrote:
NumRows = 1006 Range("R2").FormulaR1C1 = "=VALUE(RC[-1])" Range("R2").AutoFill Destination:=Range("R2:R" & NumRows) BTW. I tested it and it worked. Thanks John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
dynamically changing text color | Excel Worksheet Functions | |||
changing selections dynamically | Excel Discussion (Misc queries) | |||
Dynamically Generated Range using Macro | Excel Worksheet Functions | |||
How do I set up a formula with a changing range in an excel macro | Excel Discussion (Misc queries) | |||
Pivottable - dynamically changing the range of cells | Excel Discussion (Misc queries) |