Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Trouble Setting Range

I am trying to establish the end of a range but keep running into an object
error. Below is a bit of code that and the error, "Method 'Range' of object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Trouble Setting Range

Selection.AutoFill Destination:=Range("H5:" & RngEnd)
--
Jim Cone
Portland, Oregon USA



"Pablo"

wrote in message
I am trying to establish the end of a range but keep running into an object
error. Below is a bit of code that and the error, "Method 'Range' of object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Trouble Setting Range

Pablo, are you sure that RngEnd shouldn't be Dimmed as Long. I always Dim my
'last rows' as Long.
Dim RngEnd As Long

Jim gave good guidance above. I just would have changed the Data Type to
Long.

Just my two cents.

Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jim Cone" wrote:

Selection.AutoFill Destination:=Range("H5:" & RngEnd)
--
Jim Cone
Portland, Oregon USA



"Pablo"

wrote in message
I am trying to establish the end of a range but keep running into an object
error. Below is a bit of code that and the error, "Method 'Range' of object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Trouble Setting Range

For the way Pablo wrote his code, RngEnd needs to be a String; here is what
is being assigned to it...

RngEnd = "H" & Drng

Drng was Dim'med as a Long and that variable is what Pablo assigned the end
of data to.

--
Rick (MVP - Excel)


"ryguy7272" wrote in message
...
Pablo, are you sure that RngEnd shouldn't be Dimmed as Long. I always Dim
my
'last rows' as Long.
Dim RngEnd As Long

Jim gave good guidance above. I just would have changed the Data Type to
Long.

Just my two cents.

Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jim Cone" wrote:

Selection.AutoFill Destination:=Range("H5:" & RngEnd)
--
Jim Cone
Portland, Oregon USA



"Pablo"

wrote in message
I am trying to establish the end of a range but keep running into an
object
error. Below is a bit of code that and the error, "Method 'Range' of
object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Trouble Setting Range

Jim - Thank you. I thought it is something like this but I was mentally stuck.

"Jim Cone" wrote:

Selection.AutoFill Destination:=Range("H5:" & RngEnd)
--
Jim Cone
Portland, Oregon USA



"Pablo"

wrote in message
I am trying to establish the end of a range but keep running into an object
error. Below is a bit of code that and the error, "Method 'Range' of object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Trouble Setting Range

Ryan - Thank you. I see the value of this. It makes the variable more
versitable.

"ryguy7272" wrote:

Pablo, are you sure that RngEnd shouldn't be Dimmed as Long. I always Dim my
'last rows' as Long.
Dim RngEnd As Long

Jim gave good guidance above. I just would have changed the Data Type to
Long.

Just my two cents.

Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jim Cone" wrote:

Selection.AutoFill Destination:=Range("H5:" & RngEnd)
--
Jim Cone
Portland, Oregon USA



"Pablo"

wrote in message
I am trying to establish the end of a range but keep running into an object
error. Below is a bit of code that and the error, "Method 'Range' of object
'_Global' failed.

Dim Drng As Long
Dim RngEnd As String

Drng = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
....
Range("H5").Select
RngEnd = "H" & Drng

Selection.AutoFill Destination:=Range("H5:RngEnd")

Any help is appreciated.

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
trouble setting colors feh Charts and Charting in Excel 3 July 10th 09 06:08 AM
Trouble Setting Up Graph With Scroll Bar Dave Marden Excel Programming 1 November 25th 07 12:45 AM
trouble setting plotarea size Albert Excel Programming 2 August 31st 06 05:00 PM
Trouble setting visible property for PivotItems ridawg Excel Programming 0 March 13th 06 02:02 PM
Trouble setting total for on chart Mark Charts and Charting in Excel 1 January 11th 05 02:21 AM


All times are GMT +1. The time now is 12:59 PM.

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

About Us

"It's about Microsoft Excel"