LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel VBA Newbies - Is there a better syntax to code the if

Hi:

I am new to VBA, I have the following code, in the If statement, how
can I code it better instead of using lots of "OR". Is there a better
way or string comparison.

================================================== ====================
Dim lcCol As String
lnColCount = ActiveSheet.UsedRange.Columns.Count 'Column Count
For j = 1 To lnColCount
lcCol = GetExcelColumn(j)

If lcCol = "G" Or lcCol = "H" Or lcCol = "AB" Or lcCol =
"AF" Then
Columns(lcCol + ":" + lcCol).Select
Selection.EntireColumn.Hidden = True
End If
Next j

================================================== ====================
Thank you
Peter
 
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
Syntax problem with code WLMPilot Excel Discussion (Misc queries) 1 March 15th 08 07:07 PM
VBA code to sum a row: syntax needed [email protected] Excel Discussion (Misc queries) 1 July 11th 05 06:41 PM
Excel VBA Newbies Peter[_50_] Excel Programming 4 November 10th 04 10:23 PM
help with code/syntax Jay Baxter Excel Programming 0 February 26th 04 08:11 PM
not for the newbies... Tereba Excel Programming 4 January 21st 04 03:05 PM


All times are GMT +1. The time now is 08:54 PM.

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"