ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CONDITIONAL DELETE (https://www.excelbanter.com/excel-programming/305642-conditional-delete.html)

sh

CONDITIONAL DELETE
 
WE EXPORT STUFF FROM ACCOUNTS PROGRAM TO EXCEL AND THERE ARE A LOT OF COLUMNS THAT HAVE NO DATA. IS IT POSSIBLE TO DELETE ALL SUCH COLUMNS IN ONE STROKE THROUGH PROGRAMMING. IF SO, KINDLY LET ME KNOW.

ALSO, THERE USED TO BE AN EDIT DELETE COMMAND IN EXCEL. NOW THERE IS AN EDIT DELETE ROW COMMAND. I CAN'T FIND THE NORMAL COMMAND ANYWHERE. PLEASE GUIDE. THANK YOU.
--
LEARNING MS OFFICE THOROUGHLLY

Norman Jones

CONDITIONAL DELETE
 
Hi SH,

For your information, your type of block upper case uasge is regarded as
impolite shouting. That aside, it is disconcerting and unpleasant.

To delete your blank columns, try:

Sub DeleteBlankCols()
Dim WB As Workbook
Dim WS As Worksheet
Dim iCol As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

Set WB = ActiveWorkbook '<<<<<<<<<<<<<CHANGE TO SUIT
Set WS = ActiveSheet '<<<<<<<<<<<<<CHANGE TO SUIT

For iCol = WS.UsedRange.Columns.Count To 1 Step -1
If Application.CountA(Columns(iCol).Cells) = 0 Then
Columns(iCol).Delete
End If
Next
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


---
Regards,
Norman



"SH" wrote in message
...
WE EXPORT STUFF FROM ACCOUNTS PROGRAM TO EXCEL AND THERE ARE A LOT OF

COLUMNS THAT HAVE NO DATA. IS IT POSSIBLE TO DELETE ALL SUCH COLUMNS IN ONE
STROKE THROUGH PROGRAMMING. IF SO, KINDLY LET ME KNOW.

ALSO, THERE USED TO BE AN EDIT DELETE COMMAND IN EXCEL. NOW THERE IS AN

EDIT DELETE ROW COMMAND. I CAN'T FIND THE NORMAL COMMAND ANYWHERE. PLEASE
GUIDE. THANK YOU.
--
LEARNING MS OFFICE THOROUGHLLY




sh

CONDITIONAL DELETE
 
Hi Norman,
Extremely sorry for replying so late. My apologies once again for the
Uppercase usage. I am not really Forum Savvy. Very nice of you to give a
whole program. I shall try and revert back ASAP. Sincere regrets once again.

Regards

Norman.

"Norman Jones" wrote:

Hi SH,

For your information, your type of block upper case uasge is regarded as
impolite shouting. That aside, it is disconcerting and unpleasant.

To delete your blank columns, try:

Sub DeleteBlankCols()
Dim WB As Workbook
Dim WS As Worksheet
Dim iCol As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

Set WB = ActiveWorkbook '<<<<<<<<<<<<<CHANGE TO SUIT
Set WS = ActiveSheet '<<<<<<<<<<<<<CHANGE TO SUIT

For iCol = WS.UsedRange.Columns.Count To 1 Step -1
If Application.CountA(Columns(iCol).Cells) = 0 Then
Columns(iCol).Delete
End If
Next
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


---
Regards,
Norman



"SH" wrote in message
...
WE EXPORT STUFF FROM ACCOUNTS PROGRAM TO EXCEL AND THERE ARE A LOT OF

COLUMNS THAT HAVE NO DATA. IS IT POSSIBLE TO DELETE ALL SUCH COLUMNS IN ONE
STROKE THROUGH PROGRAMMING. IF SO, KINDLY LET ME KNOW.

ALSO, THERE USED TO BE AN EDIT DELETE COMMAND IN EXCEL. NOW THERE IS AN

EDIT DELETE ROW COMMAND. I CAN'T FIND THE NORMAL COMMAND ANYWHERE. PLEASE
GUIDE. THANK YOU.
--
LEARNING MS OFFICE THOROUGHLLY






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com