![]() So, instead of using the Worksheet_Change event, you could use the workbook’s BeforePrint event, to reduce the Undo problem. Note: As Jeff Weir pointed out in the comments below, this code will wipe out the Undo stack, so you won’t be able to undo any steps you’ve previously taken. ![]() The code that I use is based on an old Excel newsgroup example, that was posted by Excel MVP, Jim Rech. We want the row height to adjust if the OrderNote range is changed, so we’ll add code to the Worksheet_Change event. The merged cells are named OrderNote, and that name will be referenced in the event code. To fix the worksheet, so the merged cells adjust automatically, you can add event code to the worksheet. That works well, as long as you remember to do it, but it can be a nuisance, if the text changes frequently.Īnd if you forget to adjust the row height, you might print the order form, while key instructions are hidden. When the cells are merged in row 10, the row height has to be manually adjusted when the text changes. Usually, if you add more text to a single cell, and Wrap Text is turned on, the row height automatically adjusts, to fit the text. Adjusting the column width would affect the product list that starts in row 12, so that’s not an option. However, if the notes will be two or more lines, you’ll need to merge the cells, and turn on Wrap Text. ![]() If the note will always be short, there’s no need to merge the cells – just let the text flow across the columns. In the example shown below, there is an order form, and space for a note about the order. As long as you avoid merging table cells, and proceed with caution, things might be okay. Occasionally though, you might have no choice but to use one or more merged cells on a worksheet. You’ll run into more problems if you try to autofit merged cell row height. Merged cells can cause problems, especially when they’re in a table that you’ll be sorting and filtering. You’ve most likely heard this warning - “Avoid merged cells in your Excel worksheets!”, and that is excellent advice. ![]()
0 Comments
Leave a Reply. |