Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selecting between two ranges

I have done some very large programs in VB, but I have always had
trouble with Excel objects.

I want to clear rows on a spreadsheet - from a named range row and the
last used row on the spreadsheet.

My attempt is like this:

OutRow = .Range("MonteCarloPaste").Row
Range(.Cells(OutRow, 1), .Cells(OutRow, 1).SpecialCells
(xlCellTypeLastCell)).ClearContents

(It is inside a With statement referring to the sheet in question.)

Even the following doesn't work:

Range(.Range("A6"), .Range("A6").SpecialCells
(xlCellTypeLastCell)).ClearContents

Annoyingly, the following does work fine:

..Cells(OutRow, 1).SpecialCells(xlCellTypeLastCell).Value

What I am doing wrong?

Thanks for any help in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Selecting between two ranges

On May 6, 9:56*am, "
wrote:
I have done some very large programs in VB, but I have always had
trouble with Excel objects.

I want to clear rows on a spreadsheet - from a named range row and the
last used row on the spreadsheet.

My attempt is like this:

OutRow = .Range("MonteCarloPaste").Row
*Range(.Cells(OutRow, 1), .Cells(OutRow, 1).SpecialCells
(xlCellTypeLastCell)).ClearContents

(It is inside a With statement referring to the sheet in question.)

Even the following doesn't work:

Range(.Range("A6"), .Range("A6").SpecialCells
(xlCellTypeLastCell)).ClearContents

Annoyingly, the following does work fine:

.Cells(OutRow, 1).SpecialCells(xlCellTypeLastCell).Value

What I am doing wrong?

Thanks for any help in advance!


Johny Eldham,

Since your code is inside a With statement, you need to qualify your
range, i.e. you are missing a "." before Range(.Range("A6"), .Range
("A6").SpecialCells(xlCellTypeLastCell)).ClearCont ents. It should
read ".Range(.Range("A6"), .Range("A6").SpecialCells
(xlCellTypeLastCell)).ClearContents". ".Cells(OutRow, 1).SpecialCells
(xlCellTypeLastCell).Value" works because you qualified it with a "."
before "Cells".

Best,

Matthew Herbert

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting between two ranges

On 6 May, 15:16, wrote:
On May 6, 9:56*am, "



wrote:
I have done some very large programs in VB, but I have always had
trouble with Excel objects.


I want to clear rows on a spreadsheet - from a named range row and the
last used row on the spreadsheet.


My attempt is like this:


OutRow = .Range("MonteCarloPaste").Row
*Range(.Cells(OutRow, 1), .Cells(OutRow, 1).SpecialCells
(xlCellTypeLastCell)).ClearContents


(It is inside a With statement referring to the sheet in question.)


Even the following doesn't work:


Range(.Range("A6"), .Range("A6").SpecialCells
(xlCellTypeLastCell)).ClearContents


Annoyingly, the following does work fine:


.Cells(OutRow, 1).SpecialCells(xlCellTypeLastCell).Value


What I am doing wrong?


Thanks for any help in advance!


Johny Eldham,

Since your code is inside a With statement, you need to qualify your
range, i.e. you are missing a "." before Range(.Range("A6"), .Range
("A6").SpecialCells(xlCellTypeLastCell)).ClearCont ents. *It should
read ".Range(.Range("A6"), .Range("A6").SpecialCells
(xlCellTypeLastCell)).ClearContents". *".Cells(OutRow, 1).SpecialCells
(xlCellTypeLastCell).Value" works because you qualified it with a "."
before "Cells".

Best,

Matthew Herbert


Yes, that worked! Thanks a lot!
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
Selecting Various Ranges [email protected] Excel Programming 1 July 23rd 07 08:10 PM
Selecting ranges by dates [email protected] Excel Programming 1 July 25th 06 07:32 PM
Selecting Ranges Barb Reinhardt Excel Programming 3 February 7th 06 07:23 PM
Selecting ranges Steve Wood Excel Programming 1 August 24th 04 02:16 PM
selecting ranges MDC Excel Programming 1 July 24th 03 03:34 PM


All times are GMT +1. The time now is 08:50 AM.

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"