Troubleshoot:Deleting selected rows and blank columns. Error

Deleting selected rows and blank columns.

Hi All,
 
I am regularly dowloading SAP information into excel.  Usually, the data shows up in excel with both blank rows and columns.  The real meat of the infomation normally starts from Row 6 (with the Column headings in Row 6).  So, I would like to run a vb script
to delete Rows 1 to 5.  Also, Row 7 is blank.  The financial information then starts from Row 8.  In addition, I have blank columns that also needs to be deleted.
 
Is there a way I can run a VB Script that first deletes the first 5 rows and then evaluates the file to delete selected rows/blank columns?  My columns usually extend 20+ (anywhere between X to AD) and so a manual cleanup takes a wee bit of time.  Thanks.
 
Regards,
Sam.

Solutions to the Problem Deleting selected rows and blank columns.

Download SmartPCFixer to Fix It (Free)

Hi,
 
The code I gave you will delete all blanks rows and columns, if it's missing column A then it has some data in somewhere.
You may not be able to see the data, it might be a space or some other non-printing character.
What we can do is force the macro
to delete columns A like this.
Note I've also added some comments in the code to explain what's going on.
 
Sub Cleanup()
Dim LastRow As Long, LastColumn As Long
Dim x As Long
'Delete first 5 rows and column A
ActiveSheet.Range("A1:A5").EntireRow.Delete
ActiveSheet.Range("A1").EntireColumn.Delete
'Find last use column on worksheet
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
'Find last use row on worksheet
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
'delete all blank rows
For x = LastRow To 1 Step -1
    If Application.CountA(Rows(x)) = 0 Then
        Rows(x).Delete
    End If
Next
'delete all blank columns
For x = LastColumn To 1 Step -1
    If Application.CountA(Columns(x)) = 0 Then
        Columns(x).Delete
    End If
Next
End Sub

To check for Windows updates

  1. Open Windows Update by clicking the Start button Picture of the Start button, clicking All Programs, and then clicking Windows Update.
  2. In the left pane, click Check for updates, and then wait while Windows looks for the latest updates for your computer.
  3. If any updates are found, click Install updates. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

Another Safe way to Repair the Problem: Deleting selected rows and blank columns.:

How to Fix Deleting selected rows and blank columns. with SmartPCFixer?

1. Download Error Fixer. Install it on your computer.

2. After the scan is done, you can see the errors and problems which need to be fixed.

3. The Fixing part is done, the speed of your computer will be much higher than before and the errors have been fixed.


Related: How to Update & Download NVidia GeForce 6100/nForce 420 WHQL Certified driver v.178.13,How to Update & Download NVidia GeForce 7600 GS Video Driver v.295.75 Certified,How Can I Update & Download NVidia GeForce 820M Driver v.344.48 WHQL,[Solved] Download NVidia GeForce GTX 560M VGA Driver v.296.17 Certified,Way to Update & Herunterladen NVidia GeForce GT 130M Video Treiber v.295.75 Certified,How to Update & Download SONY SVE14A1X1RH Realtek Ethernet Driver,Where to Download SONY SVS13A2W9ES Bluetooth Driver (Intel) v.2.6 - 2.6.23.40059,Best Way to Update & Download SONY VGN-CR203E Conexant HDAUDIO SoftV92 Data Fax Modem with SmartCP Setup Program v.7.62.0.50 driver,Best Way to Download SONY VGN-FE790G/N Wireless LAN Driver v.10.6.0.29,Method to Update & Download SONY VGN-NR31Z/S Firmware Extension Parser Device v.8.0.2.3,How to Fix Error 0x0000c1f5 Solución?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error
Read More: Default Gateway will not save on any network adapter,How to Fix Error - Destop icons have disappeared from the desktop.?,How to Fix Problem - Dell Studio Desktop, Windows 7 blue screens every few hours.?,Fast Solution to Problem: Desktop gadgets panel has stopped working in Windows 7.,Troubleshooter of Error: desktop tile missing
Comments