LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default how to delete unselected columns in a table, thanks

Thanks.

I'm trying.
best regards
jiang
"BrianB " wrote in message
...
Something like this :-

'------------------------------------------------------
Private Sub CommandButton1_Click()
Dim ColumnName As String
Dim ListBoxItem As String
Dim MatchColumn As Boolean
'---------------------------
c = 1
Do
MatchColumn = False
ColumnName = UCase(ActiveSheet.Cells(1, c).Value)
For i = 0 To ListBox2.ListCount - 1
ListBoxItem = UCase(ListBox2.List(i))
If ListBoxItem = ColumnName Then
MatchColumn = True
Exit For
End If
Next
If MatchColumn = False Then
ActiveSheet.Columns(c).EntireColumn.Delete
Else
c = c + 1
End If
Loop While ActiveSheet.Cells(1, c).Value < ""
'---------------------------
End Sub
'-----------------------------------------


---
Message posted from http://www.ExcelForum.com/



 
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
Sorting in a Pivot Table unselected fields Marc Excel Worksheet Functions 1 May 15th 10 12:20 AM
How to delete at once empty columns in a table? capxc Excel Discussion (Misc queries) 1 July 19th 08 08:28 PM
Delete Unselected Rows Richard Excel Discussion (Misc queries) 2 August 23rd 06 04:24 PM
merge text from 2 columns into 1 then delete the old 2 columns sleepindogg Excel Worksheet Functions 4 March 30th 06 07:25 PM
Pivot Table Creating New Columns that Subtract Two Existing Columns den4673 Excel Discussion (Misc queries) 3 December 17th 04 01:31 PM


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