Morning All,
Wondered if you could assist. I have a report that lists a load of projects (column A e.g.), with a division (column B) with the sales (column C) and costs (D) for the period. Column E has a calculation of the margin (column C-D) and column F is the profit% (column E/C).
The data is imported by a macro and then sorted and sub-totalled by division. The sales, costs and margin columns have a sum total by division inserted by the macro, but I'm struggling with the margin % as I can't just sum it as part of the macro (it needs to be the total margin for the division / divided the total sales for the division).
I created the code below to select the column that contains the blank cells where the formula needs to go at the end of each division, but I'm struggling how to make the formula look at the relevant cells on the same row.
Wondered if you could assist. I have a report that lists a load of projects (column A e.g.), with a division (column B) with the sales (column C) and costs (D) for the period. Column E has a calculation of the margin (column C-D) and column F is the profit% (column E/C).
The data is imported by a macro and then sorted and sub-totalled by division. The sales, costs and margin columns have a sum total by division inserted by the macro, but I'm struggling with the margin % as I can't just sum it as part of the macro (it needs to be the total margin for the division / divided the total sales for the division).
I created the code below to select the column that contains the blank cells where the formula needs to go at the end of each division, but I'm struggling how to make the formula look at the relevant cells on the same row.
VBA Code:
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 1).Select
For Each cell In Selection
If cell.Value = vbNullString Then cell.formula =
Next cell