Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Use counter to copy formulas

I have a named range "storecntr" that gives me the number of stores on a
worksheet. A formula is entered into cell A2 of another sheet that needs to
be copied down for all the stores. I want to use storecntr to tell how many
rows to copy the formula down, but as usual I'm having trouble because I
swear I have no logic. Any help would be appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Use counter to copy formulas

Hi,
Try this:

Range("a2").Resize(Range("storecntr"), 1).Formula = Range("a2").Formula

HTH

"cottage6" wrote:

I have a named range "storecntr" that gives me the number of stores on a
worksheet. A formula is entered into cell A2 of another sheet that needs to
be copied down for all the stores. I want to use storecntr to tell how many
rows to copy the formula down, but as usual I'm having trouble because I
swear I have no logic. Any help would be appreciated. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Use counter to copy formulas

Toppers, thanks for the response. I'm getting a Method 'Range of object
_Global' failed error. Any ideas?

"Toppers" wrote:

Hi,
Try this:

Range("a2").Resize(Range("storecntr"), 1).Formula = Range("a2").Formula

HTH

"cottage6" wrote:

I have a named range "storecntr" that gives me the number of stores on a
worksheet. A formula is entered into cell A2 of another sheet that needs to
be copied down for all the stores. I want to use storecntr to tell how many
rows to copy the formula down, but as usual I'm having trouble because I
swear I have no logic. Any help would be appreciated. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Use counter to copy formulas

Hi,
You will get this message if your named range is not defined or is
mis-spelled.
Otherwise ... no idea!

"cottage6" wrote:

Toppers, thanks for the response. I'm getting a Method 'Range of object
_Global' failed error. Any ideas?

"Toppers" wrote:

Hi,
Try this:

Range("a2").Resize(Range("storecntr"), 1).Formula = Range("a2").Formula

HTH

"cottage6" wrote:

I have a named range "storecntr" that gives me the number of stores on a
worksheet. A formula is entered into cell A2 of another sheet that needs to
be copied down for all the stores. I want to use storecntr to tell how many
rows to copy the formula down, but as usual I'm having trouble because I
swear I have no logic. Any help would be appreciated. Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Use counter to copy formulas

I can't see the whole history of this thread, but just to add another
possibility which may or may not be applicable.

It could depend on where the code is located. If the code is in a sheet
module of sheet1 and storecntr is a workbook level range that references a
range in Sheet2, you will get that error. In that case you would need


Range("a2").Resize(Worksheets("Sheet2").Range( _
"storecntr"), 1).Formula = Range("a2").Formula

as an example. (Range("A2") is assumed to be on Sheet1 - same sheet as the
code)

--
Regards,
Tom Ogilvy


"Toppers" wrote in message
...
Hi,
You will get this message if your named range is not defined or

is
mis-spelled.
Otherwise ... no idea!

"cottage6" wrote:

Toppers, thanks for the response. I'm getting a Method 'Range of object
_Global' failed error. Any ideas?

"Toppers" wrote:

Hi,
Try this:

Range("a2").Resize(Range("storecntr"), 1).Formula =

Range("a2").Formula

HTH

"cottage6" wrote:

I have a named range "storecntr" that gives me the number of stores

on a
worksheet. A formula is entered into cell A2 of another sheet that

needs to
be copied down for all the stores. I want to use storecntr to tell

how many
rows to copy the formula down, but as usual I'm having trouble

because I
swear I have no logic. Any help would be appreciated. Thanks.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Use counter to copy formulas

Thanks Tom.

I put my code in a general module rather than sheet module. When I tried my
code in a worksheet module I got the error message "Application-defined or
Object-defined error" which is not the error reported; however, your code
removed my error. (The named range was on Sheet2).

Is the lesson that I should always fully qualify variables?

Thanks again.


"Tom Ogilvy" wrote:

I can't see the whole history of this thread, but just to add another
possibility which may or may not be applicable.

It could depend on where the code is located. If the code is in a sheet
module of sheet1 and storecntr is a workbook level range that references a
range in Sheet2, you will get that error. In that case you would need


Range("a2").Resize(Worksheets("Sheet2").Range( _
"storecntr"), 1).Formula = Range("a2").Formula

as an example. (Range("A2") is assumed to be on Sheet1 - same sheet as the
code)

--
Regards,
Tom Ogilvy


"Toppers" wrote in message
...
Hi,
You will get this message if your named range is not defined or

is
mis-spelled.
Otherwise ... no idea!

"cottage6" wrote:

Toppers, thanks for the response. I'm getting a Method 'Range of object
_Global' failed error. Any ideas?

"Toppers" wrote:

Hi,
Try this:

Range("a2").Resize(Range("storecntr"), 1).Formula =

Range("a2").Formula

HTH

"cottage6" wrote:

I have a named range "storecntr" that gives me the number of stores

on a
worksheet. A formula is entered into cell A2 of another sheet that

needs to
be copied down for all the stores. I want to use storecntr to tell

how many
rows to copy the formula down, but as usual I'm having trouble

because I
swear I have no logic. Any help would be appreciated. Thanks.




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
Copy several formulas from.... Shane Devenshire[_2_] Excel Worksheet Functions 1 December 9th 08 04:52 PM
Copy formulas STS Excel Worksheet Functions 2 March 24th 08 01:55 PM
automatically copy formulas down columns or copy formulas all the HowlingBlue Excel Worksheet Functions 1 March 16th 07 11:11 PM
How do I copy formulas but using the same range each time I copy Laffin Excel Worksheet Functions 2 June 22nd 06 04:17 PM
Range COPY function - how to copy VALUES and not formulas James Cooke Excel Programming 1 August 21st 03 07:04 PM


All times are GMT +1. The time now is 11:51 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"