in Numbers how to delete all entries below a certain row

in "Numbers" how to delete all data entries below a selected row?


Posted on Jan 3, 2023 2:16 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 3, 2023 9:03 PM

Select a cell in the leftmost column of the first row from which you want to delete content.

Scroll to the last row of the table, then command-click in the rightmost cell of that row to expand the selection to ALL cells between the two selected cells.


With all cells in that block now selected. press Delete.


Regards,

Barry

7 replies
Question marked as Top-ranking reply

Jan 3, 2023 9:03 PM in response to jeffl

Select a cell in the leftmost column of the first row from which you want to delete content.

Scroll to the last row of the table, then command-click in the rightmost cell of that row to expand the selection to ALL cells between the two selected cells.


With all cells in that block now selected. press Delete.


Regards,

Barry

Jan 3, 2023 9:49 PM in response to Badunit

Here is a revised script for the "Clear Data" shortcut. It has a different take on the meaning of "clear data". Hopefully I covered all bases.

  • Formulas are left alone
  • Star ratings are set to 0
  • Checkboxes are unchecked
  • Sliders and steppers are set to their minimums
  • Pop up menus will look as though "start with blank" has been selected. I'd like to set them to their "start with" selection but I do not know how to do it (unless the selection was "start with blank").
  • Numbers, dates, text, durations are all deleted.


tell application "Numbers"
	tell front document to tell active sheet
		tell (first table whose selection range's class is range)
			--set selRng to selection range
			repeat with aCell in (get selection range)'s cells
				try
					tell aCell
						if its formula is not missing value then
							--do nothing if it is a formula
						else if its format is rating then
							-- set ratings to zero
							set its value to 0
						else if its format is checkbox then
							-- uncheck checkboxes
							set its value to false
						else if its format is slider or its format is stepper then
							-- set slider and stepper values to min value
							set its value to -1.0E+308
						else if its format is pop up menu then
							-- clear popups but leave them as pop ups
							-- would like to set them to their "start with" value but do not know how
							set p1 to properties of aCell
							set value of aCell to ""
							set format of aCell to p1
						else
							-- clear numbers, durations, text, dates
							set its value to ""
						end if
					end tell
				end try
			end repeat
		end tell
	end tell
end tell


Jan 3, 2023 7:58 PM in response to jeffl

Assuming you mean you want to delete the contents of cells that have data in them while leaving alone all cells that have formulas, take a look at SGIII's response in this thread:


In numbers I want to delete cell content … - Apple Community


Install the shortcut. Select the rows/cells you want to clear then run the shortcut. Cells with formulas will be left alone. All others will be cleared of their data.


EDIT: I noticed just now that the shortcut does not remove date values or text entries. I see in the AppleScript why that happens but I do not know why SGIII wrote it that way.

Jan 4, 2023 8:19 AM in response to SGIII

My comment was perhaps poorly worded. Part of the "is it data" test was to multiply the value by 1 and see if it equals the value. Text and dates fail that test, leaving them un-cleared when they, too, are data. That was the part I did not understand. Clearing everything else made sense.


My rewrite of the script was to cover how I myself would "clear" cells that had pop-ups and other structured data entry formats. I would want the format to remain, but reset to a default value.

Jan 4, 2023 8:34 AM in response to Badunit

The wording was fine. The original short and snappy script was written back sometime in the 2010s. The problem then, if I remember correctly, was a user had some cells/rows with input numbers and some with formulas, as one might see in a financial statement. So how to clear out the numbers easily while leaving the formulas in the range intact?


For me that has been by far the most common use. I've never had a reason to automate further. I don't tend to intermingle cells with different Data Formats, so manual clearing is quick and easy. I haven't gotten much into sliders and steppers and all that. Probably should.


Anyway, thanks for your helpful enhancements! I've "borrowed" them.😀


SG



Jan 4, 2023 1:04 PM in response to SGIII

I figured out how to set a pop up to the "start with" value. I had a mistake in my code. I should have been saving and later restoring the cell's format.


tell application "Numbers"
	tell front document to tell active sheet
		tell (first table whose selection range's class is range)
			--set selRng to selection range
			repeat with aCell in (get selection range)'s cells
				try
					tell aCell
						if its formula is not missing value then
							--do nothing if it is a formula
						else if its format is rating then
							-- set star ratings to zero
							set its value to 0
						else if its format is checkbox then
							-- uncheck checkboxes
							set its value to false
						else if its format is slider or its format is stepper then
							-- set slider and stepper values to min value
							set its value to -1.0E+308
						else if its format is pop up menu then
							-- set pop up menus to their "start with" value
							set f1 to format of aCell
							set value of aCell to ""
							set format of aCell to f1
						else
							-- clear numbers, durations, text, dates
							set its value to ""
						end if
					end tell
				end try
			end repeat
		end tell
	end tell
end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

in Numbers how to delete all entries below a certain row

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.