Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Why doesn't this range work?

Overall I'm trying to use a variable to set a range so that I can
autofill based on the number of rows in the spreadsheet.

I've set SprdshtPosition as an interger.


Range("I40000") = "=COUNT(R[-39999]C:R[-1]C)"
SprdshtPosition = (Range("I40000") + "1")
'SprdshtPosition will equal only a number ex:3456

Sprdsht_No_Of_Rows = ("A2:A") & SprdshtPosition
'Sprdsht_No_Of_Rows will = A2:A3456


Why doesn't one of the following work?

Selection.AutoFill Destination:=Range("A2:A") & SprdshtPosition
-or-
Selection.AutoFill Destination:=Range Sprdsht_No_Of_Rows
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Why doesn't this range work?

Are you sure that A2 is the selected cell?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete K" wrote in message
om...
Overall I'm trying to use a variable to set a range so that I can
autofill based on the number of rows in the spreadsheet.

I've set SprdshtPosition as an interger.


Range("I40000") = "=COUNT(R[-39999]C:R[-1]C)"
SprdshtPosition = (Range("I40000") + "1")
'SprdshtPosition will equal only a number ex:3456

Sprdsht_No_Of_Rows = ("A2:A") & SprdshtPosition
'Sprdsht_No_Of_Rows will = A2:A3456


Why doesn't one of the following work?

Selection.AutoFill Destination:=Range("A2:A") & SprdshtPosition
-or-
Selection.AutoFill Destination:=Range Sprdsht_No_Of_Rows



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Why doesn't this range work?

Did not look real closely at it, but I think
Selection.AutoFill Destination:=Range("A2:A") &
SprdshtPosition

needs to be:
Selection.AutoFill Destination:=Range("A2:A" &
(SprdshtPosition))


-----Original Message-----
Are you sure that A2 is the selected cell?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete K" wrote in message
. com...
Overall I'm trying to use a variable to set a range so

that I can
autofill based on the number of rows in the

spreadsheet.

I've set SprdshtPosition as an interger.


Range("I40000") = "=COUNT(R[-39999]C:R[-1]C)"
SprdshtPosition = (Range("I40000") + "1")
'SprdshtPosition will equal only a number ex:3456

Sprdsht_No_Of_Rows = ("A2:A") & SprdshtPosition
'Sprdsht_No_Of_Rows will = A2:A3456


Why doesn't one of the following work?

Selection.AutoFill Destination:=Range("A2:A") &

SprdshtPosition
-or-
Selection.AutoFill Destination:=Range

Sprdsht_No_Of_Rows


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Why doesn't this range work?

Thank you, this is the problem. I needed () around the variable.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why doesn't this range work?

You may be looking for the RESIZE property of a range.
Assuming that Sprdsht_No_Of_Rows returns the row number of the bottom of the
range
you want to fill and you want to fill starting at Cell A2, then

Selection.Autofill Destination=Range("A2").Resize(SprtshtPosition-1, 1)

or

Selection.Autofill Destination=Range(Range("A2"),Cells(SprtshtPositio n, 1))
might also work.

Stephen Rasey
WiserWays, LLC
Houston, TX

"Pete K" wrote in message
om...
Overall I'm trying to use a variable to set a range so that I can
autofill based on the number of rows in the spreadsheet.

I've set SprdshtPosition as an interger.


Range("I40000") = "=COUNT(R[-39999]C:R[-1]C)"
SprdshtPosition = (Range("I40000") + "1")
'SprdshtPosition will equal only a number ex:3456

Sprdsht_No_Of_Rows = ("A2:A") & SprdshtPosition
'Sprdsht_No_Of_Rows will = A2:A3456


Why doesn't one of the following work?

Selection.AutoFill Destination:=Range("A2:A") & SprdshtPosition
-or-
Selection.AutoFill Destination:=Range Sprdsht_No_Of_Rows





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
CTRL A doesn't work on a range of cells DianeG Excel Discussion (Misc queries) 2 June 4th 07 08:44 PM
Cant get dynamic range formula to work. Mike K Excel Worksheet Functions 2 May 4th 07 11:59 PM
SUBTOTAL(9,range) Does NOT work in AutoFilter Dane Excel Worksheet Functions 5 September 4th 05 06:06 PM
Formatting a range of cells doesn't work Stefi Excel Discussion (Misc queries) 6 August 15th 05 12:21 PM
HELP!! Range selection doesn't work pingger Excel Programming 0 July 28th 03 09:24 PM


All times are GMT +1. The time now is 10:47 AM.

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"