Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2025, 11:29 AM
Logit Logit is offline Can a cell be both blank and not blank ? Windows 10 Can a cell be both blank and not blank ? Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

The following will remove all 'empty' cells in your workbook. Test on a COPY OF YOUR WORKBOOK for safety reasons. Test for file size before then after running macro.



Code:
Sub LipoSuction()
'JBeaucaire (8/3/2009)
Dim LR As Long, LC As Long
Dim ws As Worksheet

For Each ws In Worksheets
    LR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row + 1
    LC = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column + 1

    'Clear everything below column A last cell and row 1 last cell
        ws.Range(ws.Cells(1, LC), ws.Cells(ws.Rows.Count, ws.Columns.Count)).Delete
        ws.Range(ws.Cells(LR, 1), ws.Cells(ws.Rows.Count, ws.Columns.Count)).Delete
Next ws

End Sub
Reply With Quote
  #2  
Old 03-29-2025, 09:44 PM
MartinGM MartinGM is offline Can a cell be both blank and not blank ? Windows 11 Can a cell be both blank and not blank ? Office 2021
Competent Performer
Can a cell be both blank and not blank ?
 
Join Date: May 2023
Location: England
Posts: 108
MartinGM is on a distinguished road
Default

Quote:
Originally Posted by Logit View Post
The following will remove all 'empty' cells in your workbook. Test on a COPY OF YOUR WORKBOOK for safety reasons. Test for file size before then after running macro.

Code:
Sub LipoSuction()
'JBeaucaire (8/3/2009)
Dim LR As Long, LC As Long
Dim ws As Worksheet

For Each ws In Worksheets
    LR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row + 1
    LC = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column + 1

    'Clear everything below column A last cell and row 1 last cell
        ws.Range(ws.Cells(1, LC), ws.Cells(ws.Rows.Count, ws.Columns.Count)).Delete
        ws.Range(ws.Cells(LR, 1), ws.Cells(ws.Rows.Count, ws.Columns.Count)).Delete
Next ws

End Sub
Thanks, but that isn't addressing my issue. Your procedure clears cells outside the "used" area. My "problem" cell(s) is within the used area.

See my reply to PECOFLYER

Cheers

Martin
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
IF cell in Col A is populated BUT cell in Col C is blank DELETE ROW ChrisOK Excel Programming 7 05-05-2019 09:00 PM
Can a cell be both blank and not blank ? Fill blank cell with value from adjacent cell kevinbradley57 Excel Programming 2 04-17-2018 08:40 AM
Can a cell be both blank and not blank ? Formulato say if cell is blank do this, if not blank do this. mbesspiata Excel 1 01-17-2015 05:02 AM
Can a cell be both blank and not blank ? not showing blank cell alw Excel 4 03-13-2014 01:08 PM
Can a cell be both blank and not blank ? How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft