Reduce file size..

Mashtonsmith

Board Regular
Joined
Oct 1, 2004
Messages
164
Hi all,

I'm sure this has been asked many times so apologies.

I have a worksheet where data ends at row 49301 and column CQ - yet when I hit CRTL END I'm taken to Row 49,307 and Column WYY.

I have cleared contents AND deleted columns CR - WYY but it's still going to the same position.

What else can I do?

I'm using Excel 2007.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Run this procedure.
Code:
[COLOR="Blue"]Sub[/COLOR] DeleteUnusedRange()

    [COLOR="Blue"]Dim[/COLOR] lLastRow [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR], lLastColumn [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR]
    [COLOR="Blue"]Dim[/COLOR] lRealLastRow [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR], lRealLastColumn [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR]
    
    [COLOR="Blue"]With[/COLOR] Range("A1").SpecialCells(xlCellTypeLastCell)
        lLastRow = .Row
        lLastColumn = .Column
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]

    lRealLastRow = Cells.Find("*", Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row
    lRealLastColumn = Cells.Find("*", Range("A1"), xlFormulas, , xlByColumns, xlPrevious).Column

    [COLOR="Blue"]If[/COLOR] lRealLastRow < lLastRow [COLOR="Blue"]Then[/COLOR]
        Range(Cells(lRealLastRow + 1, 1), Cells(lLastRow, 1)).EntireRow.Delete
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]If[/COLOR]
    
    [COLOR="Blue"]If[/COLOR] lRealLastColumn < lLastColumn [COLOR="Blue"]Then[/COLOR]
        Range(Cells(1, lRealLastColumn + 1), Cells(1, lLastColumn)).EntireColumn.Delete
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]If[/COLOR]
    
    ActiveSheet.UsedRange

[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
Hi all,

I'm sure this has been asked many times so apologies.

I have a worksheet where data ends at row 49301 and column CQ - yet when I hit CRTL END I'm taken to Row 49,307 and Column WYY.

I have cleared contents AND deleted columns CR - WYY but it's still going to the same position.

What else can I do?

I'm using Excel 2007.

Click Save.

It's a little quirk that Excel doesn't reset the LastCell untill the file is saved.


Also, make sure you actually Deleted the columns, not just cleared contents.
Are you pressing the Delete button on keyboard, or Right Click - Delete?
The delete key on keyboard only does "clear contents", doesn't delete the column..
 
Upvote 0
Click Save.

It's a little quirk that Excel doesn't reset the LastCell untill the file is saved.

Also, make sure you actually Deleted the columns, not just cleared contents.
Are you pressing the Delete button on keyboard, or Right Click - Delete?
The delete key on keyboard only does "clear contents", doesn't delete the column..
You can make Excel reset it by macro, if you really need to:
Code:
Sub resetlastcell()
    dummy = ActiveSheet.UsedRange.Columns.Count
    dummy = ActiveSheet.UsedRange.Rows.Count
End Sub
 
Upvote 0
Blimey, you learn something new every day! Thanks Jonmo. :-D
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top