Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selective formula pasting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Selective formula pasting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selective formula pasting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Selective formula pasting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selective formula pasting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selective formula pasting

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selective formula AleVe Excel Discussion (Misc queries) 5 March 3rd 10 05:39 PM
Formula to sum selective data. Anto111 Excel Discussion (Misc queries) 0 July 23rd 08 07:44 PM
Pasting a formula in many different workbooks Playa Excel Discussion (Misc queries) 3 July 18th 06 05:57 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM
Pasting formula as text ExcelMonkey[_190_] Excel Programming 3 March 14th 05 11:48 PM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"