|
-
Aug 31st, 2005, 04:58 PM
#1
Thread Starter
Member
[RESOLVED] Delete hidden columns
I have made a macro that moves information from one sheet to another, but when there are hidden columns it distorts the results. I would like to add code to my macro that will delete the hidden columns.
Last edited by Botillier; Sep 1st, 2005 at 01:14 PM.
-
Sep 1st, 2005, 12:32 AM
#2
Re: Delete hidden columns
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 1st, 2005, 09:58 AM
#3
Thread Starter
Member
Re: Delete hidden columns
The deleting of hidden columns would be one of the first procedures in this particular macro. I have a feeling that the appropriate code would be to select the appropriate range, loop through the selected columns, use a true/false statement to determine whether the column is hidden or not, if it isn't hidden than I would skip it, but if it is I would delete it. So far the only education that I have received on loops and if/then statements has been from this forum, I am still very new at this and don't know how to correctly use these tools.
-
Sep 1st, 2005, 01:41 PM
#4
Thread Starter
Member
Re: Delete hidden columns
I found the below code at: 'http://www.sowsoft.com/excel-macros.htm
I think that it is sort of what I am looking for except it deletes rows instead of columns, as well as, searches all worksheets. My macro will be used with the appropriate worksheet showing so I will not have to loop through all of the worksheets. I have played with this for a while without luck.
VB Code:
For i = 1 To Worksheets.Count
If Worksheets(i).Visible Then
Worksheets(i).Select
ActiveCell.SpecialCells(xlLastCell).Select
k = ActiveCell.Row
For j = 1 To k
If Rows(j).Hidden Then
Rows(j).Hidden = False
Rows(j).Delete
End If
Next j
End If
Next i
If Worksheets(1).Visible Then Worksheets(1).Select
-
Sep 1st, 2005, 01:52 PM
#5
Re: Delete hidden columns
Try this version instead
VB Code:
Dim lstcol As Integer
lstcol = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
Dim i As Integer
For i = lstcol To 1 Step -1
If Cells(1, i).EntireColumn.Hidden Then
Cells(1, i).EntireColumn.Delete
End If
Next i
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|