Try this 

Sub delete_blankcolumn()
Dim col a range
    With ActiveSheet
        For Each col In .UsedRange.Columns
              If WorksheetFunction.CountA(col) = 0 Then
                   col.Delete
              End If
        Next
    End With
End Sub


Regards
Rajan verma
+91 7838100659 [IM-Gtalk]


-----Original Message-----
From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of NOORAIN ANSARI
Sent: 26 June 2012 12:23
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Re: delete blank columns

Please use it for blank column

Sub delete_blankcolumn()
    Dim i As Long
    With ActiveSheet
        For i = .Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
              If WorksheetFunction.CountA(.Columns(i)) = 0 Then
                   ActiveSheet.Columns(i).Delete
              End If
        Next
    End With
End Sub


On Tue, Jun 26, 2012 at 12:17 PM, NOORAIN ANSARI <noorain.ans...@gmail.com>
wrote:
> Hi Smitha,
>
> you can also try it
>
> Sub delete_blankcell()
>    Dim i As Long
>    With ActiveSheet
>        For i = .Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step 
> -1
>              If WorksheetFunction.CountA(.Rows(i)) = 0 Then
>                   ActiveSheet.Rows(i).Delete
>              End If
>        Next
>    End With
> End Sub
>
>
> --
> Thanks & regards,
> Noorain Ansari
> www.noorainansari.com
> www.excelmacroworld.blogspot.com
>
> On Tue, Jun 26, 2012 at 12:01 PM, Anil Gawli <gawlianil8...@gmail.com>
wrote:
>> select the column & press Ctlr+g and go to blank and then press Alt+E 
>> D and select row and delete .
>>
>> Regards,
>> Gawli Anil
>>
>> On Tue, Jun 26, 2012 at 11:34 AM, Prince Dubey 
>> <prince141...@gmail.com>
>> wrote:
>>>
>>> Hi Smitha,
>>>
>>> Please use this Macro hope this help you.
>>>
>>> Public Sub DeleteBlankCols(strSheetName As String, strRange As 
>>> String)
>>>
>>>     Dim intCount    As Integer
>>>     Dim rng         As Range
>>>
>>>     With ThisWorkbook.Worksheets(strSheetName)
>>>         Set rng = .Range(strRange)
>>>         For intCount = 1 To rng.Columns.Count
>>>             If 
>>> Application.WorksheetFunction.CountA(rng.Columns(intCount))
>>> <> 0 Then
>>>                 rng.Columns(intCount).Delete
>>>             End If
>>>         Next
>>>     End With
>>>
>>> End Sub
>>>
>>>
>>>
>>> On Friday, 15 June 2012 11:11:12 UTC+5:30, Smitha S R wrote:
>>>>
>>>> How to delete all blank columns arising between various rows and
columns?
>>>
>>> --
>>> -- FORUM RULES (986+ members already BANNED for violation) 1) Use 
>>> concise, accurate thread titles. Poor thread titles, like Please 
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need 
>>> Advice will not get quick attention or may not be answered. 2) Don't 
>>> post a question in the thread of another member. 3) Don't post 
>>> questions regarding breaking or bypassing any security measure. 4) 
>>> Acknowledge the responses you receive, good or bad. 5) 
>>> Cross-promotion of, or links to, forums competitive to this forum in 
>>> signatures are prohibited. NOTE : Don't ever post personal or 
>>> confidential data in a workbook. Forum owners and members are not
responsible for any loss.
>>> --------------------------------------------------------------------
>>> ----------------------------------
>>> To post to this group, send email to excel-macros@googlegroups.com 
>>> To unsubscribe, send a blank email to 
>>> excel-macros+unsubscr...@googlegroups.com
>>
>>
>>
>>
>> --
>> Thanks & Regards,
>> Gawli Anil Narayan
>> Software Developer,
>> Abacus Software Services Pvt Ltd
>>
>> --
>> -- FORUM RULES (986+ members already BANNED for violation) 1) Use 
>> concise, accurate thread titles. Poor thread titles, like Please 
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need 
>> Advice will not get quick attention or may not be answered. 2) Don't 
>> post a question in the thread of another member. 3) Don't post 
>> questions regarding breaking or bypassing any security measure. 4) 
>> Acknowledge the responses you receive, good or bad. 5) 
>> Cross-promotion of, or links to, forums competitive to this forum in 
>> signatures are prohibited. NOTE : Don't ever post personal or 
>> confidential data in a workbook. Forum owners and members are not
responsible for any loss.
>> ---------------------------------------------------------------------
>> --------------------------------- To post to this group, send email 
>> to excel-macros@googlegroups.com To unsubscribe, send a blank email 
>> to excel-macros+unsubscr...@googlegroups.com



--
Thanks & regards,
Noorain Ansari
www.noorainansari.com
www.excelmacroworld.blogspot.com

--
--
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security
measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to
excel-macros+unsubscr...@googlegroups.com


-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


Reply via email to