Hi Friends,
How to delete the blank columns in all worksheets in an Excel, and how to delete the periods which occurs in the 1st ("A") column using coding.
Attached file for your reference.
Regards,
Rakesh
Hi Friends,
How to delete the blank columns in all worksheets in an Excel, and how to delete the periods which occurs in the 1st ("A") column using coding.
Attached file for your reference.
Regards,
Rakesh
Do a Find and Replace on column A, but be sure to copy from one of the cells as they are ellipsis (...) not dots
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
To delete the blank cols
[vba]
Public Sub ProcessData()
Dim Lastcol As Long
Dim i As Long
Application.ScreenUpdating = False
With ActiveSheet
Lastcol = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Column
For i = Lastcol To 2 Step -1
If .Cells(3, i).Value = "" Then
.Columns(i).Delete
End If
Next i
End With
Application.ScreenUpdating = True
End Sub[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Hi James,
Thanks for your kind help. Its working fine. But it Deletes only in the Active sheet. How to Delete in all Sheets.
Thanks,
Rakesh
[VBA]Dim sh as worksheet
for each sh in sheets
With sh
LastCol ' etc.[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Probably best to use
[vba]
For Each sh In Activeworkbook.Worksheets
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Hi James,
Where to insert this line?
For Each sh In Activeworkbook.Worksheet
Thanks,
Rakesh
[vba]
Public Sub ProcessData()
Dim sh As Worksheet
Dim Lastcol As Long
Dim i As Long
Application.ScreenUpdating = False
For Each sh In Activeworkbook.Worksheets
With ActiveSheet
Lastcol = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Column
For i = Lastcol To 2 Step -1
If .Cells(3, i).Value = "" Then
.Columns(i).Delete
End If
Next i
End With
Next sh
Application.ScreenUpdating = True
End Sub [/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber