Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I'm very much a novice at VBA and have created a macro which includes a formula to calculate a sales parameter. However as the number of rows in the range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way is to set a range object to the used range.
Dim rng As Range Set rng = Range("A1", Range("A1").End(xlDown)) rng.Formula = "=B1" -- HTH Bob Phillips "Dave L" wrote in message ... Hi I'm very much a novice at VBA and have created a macro which includes a formula to calculate a sales parameter. However as the number of rows in the range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob
Bob Phillips wrote: One way is to set a range object to the used range. Dim rng As Range Set rng = Range("A1", Range("A1").End(xlDown)) rng.Formula = "=B1" Hi I'm very much a novice at VBA and have created a macro which includes a formula to calculate a sales parameter. However as the number of rows in the range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200507/1 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One possible solution asuming that your starts in A3 :
Sub Macro1() ' Dim MyRange As Range Set MyRange = Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) End Sub If you want to extand the range to include colums B, C, D and E as well replace Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) with Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 4)) "Dave L" wrote in message ... Hi I'm very much a novice at VBA and have created a macro which includes a formula to calculate a sales parameter. However as the number of rows in the range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
alf bryn wrote:
One possible solution asuming that your starts in A3 : Sub Macro1() ' Dim MyRange As Range Set MyRange = Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) End Sub If you want to extand the range to include colums B, C, D and E as well replace Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) with Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 4)) Hi [quoted text clipped - 3 lines] range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200507/1 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tanks Alf
alf bryn wrote: One possible solution asuming that your starts in A3 : Sub Macro1() ' Dim MyRange As Range Set MyRange = Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) End Sub If you want to extand the range to include colums B, C, D and E as well replace Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp)) with Range(Range("A3"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 4)) Hi [quoted text clipped - 3 lines] range will change month on month I need to alter the cell range that the formula is pasted into. Is this possible? -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selective formula | Excel Discussion (Misc queries) | |||
Formula to sum selective data. | Excel Discussion (Misc queries) | |||
Pasting a formula in many different workbooks | Excel Discussion (Misc queries) | |||
Pasting on Filtered Data Sheets without pasting onto hidden cells | Excel Discussion (Misc queries) | |||
Pasting formula as text | Excel Programming |