clearing columns in VBA
But these work, too:
Option Explicit
Sub ClearColumnTest()
ActiveSheet.Columns("A").Clear
ActiveSheet.Columns("C:C").Clear
End Sub
IIRC, the first may cause problems in some earlier versions of excel.
And it's more than a hold over. I'm guessing that it allows some flexibility
for the user. (There are people who actually like R1C1 reference style!)
You can use: Tools|Options|General|check R1C1 Reference style
and write all your formulas using column numbers:
=r3c5
or
=r[-1]c[7]
====
My personal preference is to use:
ActiveSheet.Range("A:A").Clear
or
ActiveSheet.Range("A1").entirecolumn.Clear
Then I can change it to:
ActiveSheet.Range("A:C,d:D,g:H").Clear
without swearing when I do:
ActiveSheet.Columns("A:C,d:D,g:H").Clear
Dave F wrote:
I understand the following clears column A of the active sheet:
Sub ClearColumnTest()
ActiveSheet.Range("A:A").Clear
End Sub
I also understand that this does the same thing:
Sub ClearColumnTest()
ActiveSheet.Columns(1).Clear
End Sub
But when creating formulas in Excel (as opposed to in VBA) we refer to
column 1 as column A. Why the discrepancy?
Is this a holdover from the R1C1 reference style of Lotus?
Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.
--
Dave Peterson
|