Nov 20 2021 10:01 AM
When a worksheet contains rows with different heights, I would expect those heights to be automatically adjusted during a sort of the rows in that sheet. Alas, this appears to not be the case (At least I haven't been able to make that happen). Can I make that happen?
Nov 20 2021 10:42 AM
You can manually adjust the column width or row height or automatically resize columns and rows to fit the data.
Change the column width or row height in Excel
Additional Information:
Change the column width and row height
Hope I was able to help you with this info.
NikolinoDE
I know I don't know anything (Socrates)
Nov 20 2021 10:46 AM
Nov 20 2021 10:56 AM
Here automatic adjustment with VBA on all cells
See the attached file with examples where you can try it out yourself.
Enjoy excel
Nov 21 2021 03:00 PM
Nov 21 2021 11:42 PM
I am pleased that you are satisfied, I hope to see you again in the future here in the forum.
Welcome to your Excel discussion space!
Also wish you have fun with Excel.
Feb 06 2022 09:34 AM
Hello Niko...
Your example file below is exactly what I'm trying to do. But apparently I'm not be doing the VBA correctly, because it's not working for me either. I even tried copying your code exactly, but it didn't do a thing. (I've attached your example to clarify what I'm referring to.)
Feb 06 2022 10:42 AM
VBA code "behind" a worksheet or a workbook may not work in Excel
o edit code "behind" a worksheet or a workbook:
Activate the Visual Basic Editor (press ALT+F11).
In the Project Explorer window, you will see entries similar to the following:
Copy this Code in the Worksheet you like
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Target.EntireRow.AutoFit
Target.EntireColumn.AutoFit
End Sub
With this you don't need a button or any other jump starter, the sheet should behave just like the sheet I sent you. If you cannot manage it on your PC, I can only help if you send me the file (without sensitive data).
*Knowing the Excel version, as well as the operating system and storage medium (OneDrive, hard drive, Sharepoint, etc.) would be an advantage to share more detailed information.
Thank you for your understanding and patience
I know I don't know anything (Socrates)
Dec 21 2022 08:20 AM
Dec 21 2022 08:44 AM
Dec 21 2022 08:44 AM
Dec 21 2022 09:45 AM
@NikolinoDE I was able to get it to work on one of my workbooks and actually was able to remove column autofit and it still worked after sorting multiple different ways. Now my issue is.... I cant get it to do the same thing on another workbook by following the same exact example. It is odd. I have saved my add in and tried that as well with no luck. What am I doing wrong?
Dec 21 2022 09:52 AM
Dec 21 2022 11:08 AM
@NikolinoDE It will not let me attach the file. I have tried and it shows that it is not supported.
Dec 21 2022 11:27 AM
Dec 21 2022 11:33 AM
Dec 22 2022 05:19 AM
Jan 03 2023 05:14 PM - edited Jan 03 2023 05:25 PM
Just for anyone else that runs into this, Worksheet_Change() did not work for me, but putting the code under Worksheet_SelectionChange() did even though I'm not actually changing the selection--it works even if I've got a random cell above the table selected. <shrug>
Thanks for the tip, just needed to find the event that worked for me even though that event doesn't make any sense. I just needed the row part, not the columns.