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

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
....but it doesn's work. I just want to erase the contents of the cells in
the specified range.
I patched the problem like this but I do not like that solution.
' ***
Dim intK As Integer
With rngSuppr
For intK = 1 To intNbCol
.Cells(intIndex + 1, intK).Value = ""
Next intK
End With
' ***
Can someone tell me what the right syntax is?

Thanks.
--
Jac Tremblay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Range problem

Rather than use:
some_range.Value=""
use:
some_range.Clear
--
Gary''s Student - gsnu200812


"Jac Tremblay" wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.
I patched the problem like this but I do not like that solution.
' ***
Dim intK As Integer
With rngSuppr
For intK = 1 To intNbCol
.Cells(intIndex + 1, intK).Value = ""
Next intK
End With
' ***
Can someone tell me what the right syntax is?

Thanks.
--
Jac Tremblay

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Range problem

Hi Gary,
That is not the point. I could use .ClearContents or any other ClearStuff
method, the code doesn't work because the
rngSuppr.Range(rngSuppr.Cells(intIndex + 1, 1), rngSuppr.Cells(intIndex + 1,
intNbCol))... doesn't do the job.
The problem is in there...
Thanks
--
Jac Tremblay


"Gary''s Student" wrote:

Rather than use:
some_range.Value=""
use:
some_range.Clear
--
Gary''s Student - gsnu200812


"Jac Tremblay" wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.
I patched the problem like this but I do not like that solution.
' ***
Dim intK As Integer
With rngSuppr
For intK = 1 To intNbCol
.Cells(intIndex + 1, intK).Value = ""
Next intK
End With
' ***
Can someone tell me what the right syntax is?

Thanks.
--
Jac Tremblay

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range problem

when u use range you need to reference with a string such as "A1", and
to select a bunch of cells "A1:D10"
also any single range like cels(1,1), use cells(1,1).address to return
the string value of address

so

With rngSuppr
.Range(.Cells(intIndex + 1, 1).address & ":" & .Cells(intIndex + 1,
intNbCol).address).Value = ""
End With
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Range problem

Hi Hanyu,
I tried your suggestion and it still doesn't work. I tried different version:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1).Address, _
.Cells(intIndex + 1, intNbCol).Address).Value = ""
End With ' Doesn't work.
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1).Address & ":" & _
.Cells(intIndex + 1, intNbCol).Address).Value = ""
End With ' Doesn't work.
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1).Address(External:=True) & ":" & _
.Cells(intIndex + 1, intNbCol).Address(External:=True)).Value = ""
End With ' Doesn't work.
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1).Address(External:=True), _
.Cells(intIndex + 1, intNbCol).Address(External:=True)).Value = ""
End With ' Bugs (gives an error).
' ***
So I will have to keep my macramé way of doing until I can find the problem.
Thanks for your time. I appreciate.
--
Jac Tremblay


" wrote:

when u use range you need to reference with a string such as "A1", and
to select a bunch of cells "A1:D10"
also any single range like cels(1,1), use cells(1,1).address to return
the string value of address

so

With rngSuppr
.Range(.Cells(intIndex + 1, 1).address & ":" & .Cells(intIndex + 1,
intNbCol).address).Value = ""
End With



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Range problem

On Mon, 10 Nov 2008 18:08:01 -0800, Jac Tremblay
wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.


Possibly you want something like:

Range(rngSuppr(intIndex + 1, 1), _
rngSuppr(intIndex + 1, intNbCol)).ClearContents

--ron
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Range problem

On Tue, 11 Nov 2008 14:06:50 -0500, Ron Rosenfeld
wrote:

On Mon, 10 Nov 2008 18:08:01 -0800, Jac Tremblay
wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.


Possibly you want something like:

Range(rngSuppr(intIndex + 1, 1), _
rngSuppr(intIndex + 1, intNbCol)).ClearContents

--ron



Another format, that more closely matches what you tried:

With rngSuppr
Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
--ron
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Range problem

Hi Ron,
You are absolutely correct. Both ways work fine. It seems that the period
before the Range object was the problem. I tried these two versions that give
the same result.
Range(rngSuppr(intIndex + 1, 1), rngSuppr(intIndex + 1, _
intNbCol)).ClearContents
Range(rngSuppr(intIndex + 1, 1), rngSuppr(intIndex + 1, _
intNbCol)).Value = ""
I tried them also when the worksheet where the data was beeing erased was
not the active one and they both work fine.
Thank you very much and have a good day.

--
Jac Tremblay


"Ron Rosenfeld" wrote:

On Mon, 10 Nov 2008 18:08:01 -0800, Jac Tremblay
wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.


Possibly you want something like:

Range(rngSuppr(intIndex + 1, 1), _
rngSuppr(intIndex + 1, intNbCol)).ClearContents

--ron

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Range problem

Hi again Ron,
I tried this version as well and it is perfect. My problem now is to choose
between the three version that work well.
With rngSuppr
Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With

Thanks again.
--
Jac Tremblay


"Ron Rosenfeld" wrote:

On Tue, 11 Nov 2008 14:06:50 -0500, Ron Rosenfeld
wrote:

On Mon, 10 Nov 2008 18:08:01 -0800, Jac Tremblay
wrote:

Hi, I have this code that should work:
' ***
With rngSuppr
.Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
' ***
...but it doesn's work. I just want to erase the contents of the cells in
the specified range.


Possibly you want something like:

Range(rngSuppr(intIndex + 1, 1), _
rngSuppr(intIndex + 1, intNbCol)).ClearContents

--ron



Another format, that more closely matches what you tried:

With rngSuppr
Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With
--ron

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Range problem

On Tue, 11 Nov 2008 12:09:03 -0800, Jac Tremblay
wrote:

Hi again Ron,
I tried this version as well and it is perfect. My problem now is to choose
between the three version that work well.
With rngSuppr
Range(.Cells(intIndex + 1, 1), _
.Cells(intIndex + 1, intNbCol)).Value = ""
End With

Thanks again.
--
Jac Tremblay


Without actually measuring the time to accomplish the task using the different
codings, my bias would be to use the shortest (fewest key strokes) or the one
with the fewest "calls".

But I'm glad you've got it working now.
--ron
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
A problem with Set (Range) Peter Excel Programming 1 November 15th 05 09:31 PM
Range problem Ali Baba Excel Programming 1 September 10th 05 01:10 AM
Range problem David Gerstman Excel Programming 2 May 24th 05 07:11 PM
Range problem Mark[_36_] Excel Programming 6 February 12th 04 01:22 PM
Range problem Reno Excel Programming 7 September 19th 03 07:24 PM


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