You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Count 'line breaks' cell

I am setting up a numbers file that eventually outputs a pdf, but there's one challenge I have not yet been able to solve. If a cell does not fit the amount of text, there's a 'line break' and you continue below, and I am trying to figure out if there's a way to count the amount of lines used. I am going to use that so text that get's below a certain point will be inserted in the next cell. I've tried workarounds like counting the amount of characters, but the difference in size between 'W' and 'i' alone makes that impossible. Any ideas?

MacBook Pro 15″, macOS 10.14

Posted on Oct 19, 2020 9:44 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 20, 2020 6:04 AM

A script can tell you the height of a cell in a row.


For example, this will tell you the height of the selected cell.


tell application "Numbers"
	tell front document
		tell active sheet
			tell (first table whose class of selection range is range)
				tell first cell of selection range to return height of its row
			end tell
		end tell
	end tell
end tell



Copy-paste into Script Editor (in Applications > Utilities. Select the cell. Click the triangle 'run' button.


If "nothing happens" make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.


This is just to introduce the possibility of using a script. However, still not sure what you want to do once you know how high a row is.


SG

5 replies
Question marked as Top-ranking reply

Oct 20, 2020 6:04 AM in response to TDoeven

A script can tell you the height of a cell in a row.


For example, this will tell you the height of the selected cell.


tell application "Numbers"
	tell front document
		tell active sheet
			tell (first table whose class of selection range is range)
				tell first cell of selection range to return height of its row
			end tell
		end tell
	end tell
end tell



Copy-paste into Script Editor (in Applications > Utilities. Select the cell. Click the triangle 'run' button.


If "nothing happens" make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.


This is just to introduce the possibility of using a script. However, still not sure what you want to do once you know how high a row is.


SG

Oct 20, 2020 2:00 AM in response to TDoeven

Hi TD


What effect will counting the number of lines taken by a table, or a portion of a table, have on the end product of your project?

What effect will knowing that count have on the work flow need to produce the end result?


The effect of cells containing more than one row of text is to have room for fewer lines of text on the page.


The location of page breaks in the printed version of a numbers document (whether printed to paper or 'printed' to PDF) is fairly easy to determine directly, by pressing command-P and examining the resulting screen showing the content of each page of the current version of the document. Visually checking for wider margins at the bottoms of some pages will reveal where text wrap has made a 'tall' row wide enough to be pushed onto the next page. Temporarily setting "alternate row colours'" should make individual rows containing wrapped text quite visible,


Regards,

Barry


PS: Usage note: "amounts" are measured and tell 'how much'.

                           "numbers" are counted, and tell 'how many'.

B.

Count 'line breaks' cell

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