Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Little bit late but this works - info picked up from this site.
select the last cell in row and column that you require then run the following macro. (you can save the macro in your personal.xlsb workbook for future use. NOTE: once run just save the workbook and last cell will be the one you selected. This is a good way to reduce file size. Sub ChangeLastUsed() Dim c As Range Dim DeleteOK As Integer Set c = Selection Range(c(2), c(Cells.Rows.Count - c.Row)).EntireRow.Select DeleteOK = MsgBox("Confirm Irreversible Deletion of selected Rows ", vbYesNoCancel) If DeleteOK = vbYes Then Selection.Delete Else c.Select Exit Sub End If Range(c(, 2), c(, Cells.Columns.Count - c.Column)).EntireColumn.Select DeleteOK = MsgBox("Confirm Irreversible Deletion of Selected Columns ", vbYesNoCancel) If DeleteOK = vbYes Then Selection.Delete Else c.Select End If End Sub On Friday, July 30, 2010 3:15 PM IanC wrote: What tells Excel where the last cell is (accessed by ctrl-end)? I have a number of spreadsheets where data has been entered then deleted but ctrl-end goes to the last cell that ever had data in, not the last cell currently occupied. For example, one sheet has no data below row 144 or to the right of column AF, but ctrl-end takes me to AK170. I have tried deleting entire rows from 145 down to 200 and entire columns from AG to AZ, but still the last used cell appears to be AK170. How do I change this? I suppose one option would be to copy the relevant portions into a new sheet, but there are a lot of named ranges that I will have to recreate if I do this. -- Ian -- On Friday, July 30, 2010 3:48 PM Ron Rosenfeld wrote: There is a property called UsedRange You can change this with a VBA Macro. You should also be aware that any cells that have any kind of format applied will still be considered part of the UsedRange. To enter this Macro (Sub), <alt-F11 opens the Visual Basic Editor. Ensure your project is highlighted in the Project Explorer window. Then, from the top menu, select Insert/Module and paste the code below into the window that opens. To use this Macro (Sub), <alt-F8 opens the macro dialog box. Select the macro by name, and <RUN. ================================ Sub ResetUsedRange() ActiveSheet.UsedRange End Sub ============================= On Friday, July 30, 2010 11:33 PM Gord Dibben wrote: On a sheet, select all rows below real data range and delete those rows...........delete.........do not just clear contents. Same for all columns right of real data range. NOW..............save the workbook in order to reset the used range. Gord Dibben MS Excel MVP On Tuesday, August 03, 2010 2:14 AM IanC wrote: Ron, I tried your method which was easier to use but in most cases failed, presumably because of formatting. In those cases I used your method Gord. Although more time consuming to implement, it worked every time. Thank you both. -- Ian -- On Tuesday, August 03, 2010 6:51 AM Ron Rosenfeld wrote: Yes -- it does depend on there being nothing past that point. Ian, Gord's method can be done via a VBA macro To enter this Macro (Sub), <alt-F11 opens the Visual Basic Editor. Ensure your project is highlighted in the Project Explorer window. Then, from the top menu, select Insert/Module and paste the code below into the window that opens. To use this Macro (Sub), first select the cell that you wish to represent the Last Cell. <alt-F8 opens the macro dialog box. Select the macro by name, and <RUN. The macro will give you an opportunity to confirm the deletion, because the deletions are irreversible. ======================================= Option Explicit Sub ChangeLastUsed() Dim c As Range Dim DeleteOK As Integer Set c = Selection Range(c(2), c(Cells.Rows.Count - c.Row)).EntireRow.Select DeleteOK = MsgBox("Confirm Irreversible Deletion of selected rows", vbYesNoCancel) If DeleteOK = vbYes Then Selection.Delete Else c.Select Exit Sub End If Range(c(, 2), c(, Cells.Columns.Count - c.Column)).EntireColumn.Select DeleteOK = MsgBox("Confirm Irreversible Deletion of Selected Columns", vbYesNoCancel) If DeleteOK = vbYes Then Selection.Delete Else c.Select End If End Sub ======================================= On Sunday, August 08, 2010 8:00 PM Lynz wrote: On 31/07/2010 7:15 a.m., IanC wrote: You dont have a "set Print Area" on there do you as Ctrl End will send you to the end of that even if you have deleted the rows. Lyn On Friday, August 13, 2010 9:20 AM IanC wrote: No, it was down to formatting. In some cases there is a Pring Area, but Ctrl-End took the cursor beyond this. -- Ian -- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changing position of shapes in chart | Excel Discussion (Misc queries) | |||
images in excel keep changing position | Excel Discussion (Misc queries) | |||
Changing Right Position of Chart | Charts and Charting in Excel | |||
Changing Comment Box Position - Any solutions? | Excel Worksheet Functions | |||
CHANGING POSITION OF AUTOFILTER LIST | Excel Discussion (Misc queries) |