If in a spreadsheet you need to count down 60 rows, when someone wraps text and it goes onto a second line, is there a way to get a macro to count the 2nd line as a row, as therefore instead of going to row 60, it would count to row 59?
How about using the rowheight property? Assuming the rows are equal heights (default 12.75)
Code:
Sub Macro1()
tHeight = 0
For n = 1 To 60
x = Range("A" & n).RowHeight
tHeight = tHeight + x
Next
tHeight = (tHeight / 12.75)
'rows to exclude
exRows = tHeight - 60
Range("A1:A" & (60 - exRows)).Select
End Sub
Gaj - that's an interesting way of tackling the problem. It is then dependent on the sheet formatting. Mark, maybe it would help us if you could explain exactly why you are wanting to do this?
This needs to be done as the I need to be able to set the page setup correctly. The users want to be able to wrap text, but every equivalent to 60 rows height I need to put Page Summary at the bottom of the page and have a page break as this spreadsheet needs to be set in a specific style.
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.