Microsoft KB Archive/147254

{| = XL: Macro to Delete Blank Rows and Columns in a Lotus File =
 * width="100%"|

Last reviewed: February 3, 1998

Article ID: Q147254 The information in this article applies to:
 * Microsoft Excel 98 Macintosh Edition
 * Microsoft Excel 97 for Windows
 * Microsoft Excel for Windows 95, versions 7.0, 7.0a
 * Microsoft Excel for Windows, versions 5.0, 5.0c
 * Microsoft Excel for Windows NT, version 5.0
 * Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SUMMARY
In Microsoft Excel, when a Lotus 1-2-3 WK4 file is opened and then saved into the Microsoft Excel Workbook format, the file size may increase by a large amount. This behavior occurs because formatting is applied to an entire row or column. Microsoft Excel detects and saves the formats in all of the blank cells, whereas Lotus 1-2-3 does not. You can delete these blank rows and columns manually, but that may take time. This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) you can use to speed up the process of shrinking the file by getting rid of the blank rows and columns in the file.

MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/refguide/default.asp

Sample Visual Basic Procedure
Sub DelRowCol On Error GoTo crash

For Each Item In ActiveWorkbook.Worksheets

x = InputBox("Enter the last column letter of Sheet - " & _               Item.Name) y = InputBox("Enter the last row number of Sheet - " & _               Item.Name) Item.Range(Left(Item.Range(x & ":" & x).Offset(0, 1).Address, _ InStr(Item.Range(x & ":" & x).Offset(0, 1).Address, ":") _ - 1) & ":$iv").Delete Item.Range("$" & y + 1 & ":$16384").Delete

Next Item

ActiveWorkbook.Save Exit Sub

crash: MsgBox "Error in conversion"

End Sub For additional information about opening and working with Lotus 1-2-3 WK4 files in Microsoft Excel, please see the following articles in the Microsoft Knowledge Base: ARTICLE-ID: Q123269 TITLE    : XL5: Large File Size After Saving WK4 File as Excel Workbook

ARTICLE-ID: Q122583 TITLE    : WE1130: Lotus 1-2-3 WK4 File Converter
 * }