Yes please, I've been using VBA in other sections too - but I've been teaching myself and only used it for the past 6 months on/off. Basically what I'm doing to this page is merging two-three different sections. Originally this section would only contain the Action and Action Taken parts. The Question and Observations were a different section. Comments didn't appear originally.
We've been asked by most clients to produce a smaller document. The Question & Observation section would show every question and every observation (roughly 40 A4 pages), the action and action taken section would only contain ones where there was a issue raised (usually 3-4 A4 pages) and it was a bit disjointed to reference back to the question and observation section; we had to field quite a few phone calls over the years to try and explain things (even though all the instructions are in the document). So what I'm trying to to is remove the question & observation separate section and merge it with the action section but still so the client only sees ones where there's an issue.
EDIT:
Actually i think have figured something out, not sure exactly how I got it to work, but it does; and from messing around with it I've realised I need to set up the code on the sheet where inputs are being made, as it doesn't react to changes on the sheet where the values are formulas. Only on pages where the user has made a change.
So i've inserted this code to sheet 2
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Sheet1").Range("B21:DE24").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP31:DR34").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP41:DR44").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP51:DR54").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP61:DR64").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP71:DR74").EntireRow.AutoFit
Worksheets("Sheet1").Range("DP81:DR84").EntireRow.AutoFit
End Sub
As you can see i've also checked it against the merged cells B-DE and it still works. So there isn't really the need for the DP-DR columns.
Basically all those ranges are the rows i want to auto adjust the height when the question wording changes. They're all linked to a cell in Sheet 2. If you make a change to one of those cells on sheet 2, the height of the cell on sheet 1 will automatically adjust to the correct height to fit the text.
As i said i'm a bit of a self taught novice on VBA so would be grateful if you could double check this for me?
So for example; (with the above code in Sheet2)
row 21 (F21:DE21) should have the value something like "=Sheet2!B1". Then if you make a change to sheet 2, if B1 contains a value longer than that of sheet 1 F12:DE21 it should automatically change the height of row 21 to fit because wrap text it active.
EDIT
Just FYI, the helper columns do appear to be required - no matter which ones you reference in the code.
Bookmarks