Hi Everyone,
Hope you're all in good form.
I am stuck on this. I have a worksheet containing lots of columns 300+ and data.
I am transforming this into a new worksheet with the columns re-arranged and some renamed etc.
The VB code I have so far has worked to complete these tasks OK.
However, now I need to do the above i.e. Add the values in 3 cells, subtract the value in a fourth and put the result and the fifth cell.
This is what my current code looks like - which is obviously not working
Sub CalcTotalMisusRisk()
The values in cells CZ2, DA2 and DB2 are just numbers and row 1 contains the headers hence <for i="2" to="" cells="" etc="">
but VB is kicking up the following error:
"Runtime error '13'
Type mismatch
Apologies if I haven't articulated the problem very well - I'm (as you can see) not a coder.</for>
Hope you're all in good form.
I am stuck on this. I have a worksheet containing lots of columns 300+ and data.
I am transforming this into a new worksheet with the columns re-arranged and some renamed etc.
The VB code I have so far has worked to complete these tasks OK.
However, now I need to do the above i.e. Add the values in 3 cells, subtract the value in a fourth and put the result and the fifth cell.
This is what my current code looks like - which is obviously not working
Sub CalcTotalMisusRisk()
Dim i As Long
For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Sheet2").Range("DD" & i) = ("CZ2" & i & ",DA2" & i & ",DB2" & i) - (",DC2" & i)
Next i
End SubFor i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Sheet2").Range("DD" & i) = ("CZ2" & i & ",DA2" & i & ",DB2" & i) - (",DC2" & i)
Next i
The values in cells CZ2, DA2 and DB2 are just numbers and row 1 contains the headers hence <for i="2" to="" cells="" etc="">
but VB is kicking up the following error:
"Runtime error '13'
Type mismatch
Apologies if I haven't articulated the problem very well - I'm (as you can see) not a coder.</for>