Select Case Sheet1.Range("O1").Value ' is this another sheet?ĪctiveSheet.ListObjects("tblPatients").Range. If Len(targetCell.Value) > 60 Then targetCell.wrapText = True Cells.RowHeight = 15 ' set all rows to 15 height Set targetRange = Range(w.Cells(1, 7), w.Cells(Rows.Count, 7).End(xlUp)) 'lastRow = w. ' this is a quite bad and unstable idea, see below a better one I wonder if there is something obvious how I could achieve the same but in a more efficient way? Thanks. One way to adjust the width of the column to fit it in all the text is to simply move the boundary of the column. For instance, in our case, we need to resize the rows from row 4 to row 10. To do so, First of all, we need to select the rows that we are going to work with. ![]() ![]() '\restore normal XL settings for application When formatting a spreadsheet, you may need to increase the size of all the rows to accommodate the text that it contains. We can simply regulate all rows in Excel by dragging our mouse. ' This checks value of "O1" - I store 1 there if a custom filter is onĪctiveSheet.ListObjects("tblPatients").Range.AutoFilter Field:=6ĪctiveSheet.ListObjects("tblPatients").Range.AutoFilter Field:=6, Criteria1:="=" Set targetRange = Range("G3:G" & lastRow) I base it on condition - if cell text is longer than 60 char, then wrap text and set row height. I wonder if there was a better way to set row height. I wrote a routine called through click of a button and it works, but is slow (takes a few seconds for a table with 200 entries and could become longer if we have a couple of thousand records). I have built a spreadsheet that at times requires to view "Notes" column so that all the text is visible, and sometimes so that all rows are the same height (15 works well).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |