LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Macro to delete specific cells

Thanks Bill for your detailed explanation. I can understand better those
commands now.

Orquidea

"Bill Renaud" wrote:

<<What does it do .Cells?

Whenever you see a dot (".") in front of something, it means that it is a
continuation of a preceding With statement. In the code given:

With rCell
If Not .Text = "CNR001" Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
End With

The ".Cells" would be read as: "rCell.Cells", since the line "With rCell"
is the previous With statement in effect. See Excel VBA Help on the "With"
statement for more info. Using With statements speeds up the execution of
the code, because the run-time engine has to actually process each "dot"
that it sees in the code to "drill down" to the specified property or
method for that object.

<<What does the instruction Set do?

Set must be used anytime you are initializing an object variable (a Range,
Worksheet, Chart, etc.). If you don't use it, then you simply are setting
the default property to some value. So for example, the statement:

rDelete = rSomeOtherCell

would simply set the value of whatever rDelete is currently pointing to
(maybe cell "E5") to the value in the cell pointed to by rSomeOtherCell
(i.e. "ABC"). This is not what you want in this situation. If you want to
cause the object variable rDelete to point to the same cell as
rSomeOtherCell, then you must use:

Set rDelete = rSomeOtherCell

This can be seen if you step through the code and watch the Locals window.
Click on the "+" symbol next to the variable rDelete so that the object
structure opens up. You will see all of the properties (i.e. Column, Row,
Value, Formula, Font, etc.). After executing the above statement, the Row,
Column, and Count properties of rDelete and rSomeOtherCell will be equal,
indicating that they are both pointing to the same range of cells.
--
Regards,
Bill Renaud






 
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
how to delete specific values in cells [email protected] New Users to Excel 1 August 29th 08 02:31 PM
Delete cells containing specific data? Mobility Guy Excel Discussion (Misc queries) 1 March 22nd 07 08:29 PM
macro to select cells containing specific text and delete all cells but these JenIT Excel Programming 3 March 27th 06 10:07 PM
Delete specific cells contents in a row with some locked cells in the same row trussman Excel Programming 2 March 1st 05 06:12 PM
Locate and delete specific cells David Smith Excel Discussion (Misc queries) 1 January 19th 05 04:45 PM


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