View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default cut/paste columns efficiency

Matthew Dyer was thinking very hard :
On Feb 2, 11:36*am, "Rick Rothstein"
wrote:
Here's some code to handle clearing the columns...
*Const sColsToClear As String = "A:B,E:H,J,M:Q,T,V:Z,AC"
*Dim s As Variant
*For Each s In Split(sColsToClear, ",", , vbTextCompare)
* *Columns(s).Clear
*Next


If you fill out those single column references to double references (for
example, change the J to J:J, the T to T:T, etc.), then you can clear the
columns more efficiently with this one-liner...

Range("A:B,E:H,J:J,M:Q,T:T,V:Z,AC:AC").Clear

Rick Rothstein (MVP - Excel)


I knew there were easier ways to do this stuff. This is an old macro I
coded a while ago when I was just starting. It worked and I saw no
real need to delve into ways to do certiain things more efficiently,
but I've got some spare time now and am building on previous
knowledge. Thanks for all the help guys!


You're welcome!
See Rick's better solution for clearing the columns...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc