Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Resizing my range - End row

I have used the following syntax to determine the range for a For Each
statement. However I'd like the end row to be 1 less than is returned so I
enclosed a -1 in the bracket. I'm now getting a mismatch error from VBA.
How do I fix?

Many thanks
Jacqui

Set myRng = .Range("c20", .Cells(.Rows.Count, "c").End(xlUp) - 1)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Resizing my range - End row

Hi Jaqui,

Try:

Set myRng = .Range("c20", _
.Cells(.Rows.Count, "c").End(xlUp))

Set myRng = myRng.Resize(myRng.Count - 1)


---
Regards,
Norman



"Jacqui" wrote in message
...
I have used the following syntax to determine the range for a For Each
statement. However I'd like the end row to be 1 less than is returned so
I
enclosed a -1 in the bracket. I'm now getting a mismatch error from VBA.
How do I fix?

Many thanks
Jacqui

Set myRng = .Range("c20", .Cells(.Rows.Count, "c").End(xlUp) - 1)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Resizing my range - End row

How about:

Set myRng = .Range("c20:C" & .Cells(.Rows.Count, "c").End(xlUp).row - 1)

well, as long as there was something in column C after row 1.



Jacqui wrote:

I have used the following syntax to determine the range for a For Each
statement. However I'd like the end row to be 1 less than is returned so I
enclosed a -1 in the bracket. I'm now getting a mismatch error from VBA.
How do I fix?

Many thanks
Jacqui

Set myRng = .Range("c20", .Cells(.Rows.Count, "c").End(xlUp) - 1)


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Resizing my range - End row

Try

Set myRng = .Range("c20", .Cells(.Rows.Count, "c").End(xlUp).row - 1)

HTH

"Jacqui" wrote:

I have used the following syntax to determine the range for a For Each
statement. However I'd like the end row to be 1 less than is returned so I
enclosed a -1 in the bracket. I'm now getting a mismatch error from VBA.
How do I fix?

Many thanks
Jacqui

Set myRng = .Range("c20", .Cells(.Rows.Count, "c").End(xlUp) - 1)

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
resizing a range of cells ckane Excel Discussion (Misc queries) 4 May 3rd 07 06:08 PM
Resizing a range of cells in a column ckane Excel Discussion (Misc queries) 0 May 3rd 07 02:38 PM
Resizing cells in a selection without resizing entire sheet Danielle via OfficeKB.com Excel Discussion (Misc queries) 4 August 11th 06 10:06 PM
resizing a range Tim Kredlo Excel Programming 1 September 27th 05 08:30 PM
Resizing a Range NetWave128[_3_] Excel Programming 3 April 24th 04 11:16 AM


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