ExcelApprenticeChris
New Member
- Joined
- Mar 17, 2013
- Messages
- 9
Hello 
I would like some help please regarding VBA code. I have found some lines of code that work and add an IFERROR statement to whatever I have selected at the time on my worksheet, adding the text 'No Data' if there is an error. This works and I am happy with it. Here follows is the code:
However I would like to add into this another formula which I have tried to do but my attempts lead to an error. The function I wish to add is the ROUND function which rounds the data to one decimal place e.g. on cell A1 it would be =ROUND(A1,1).
So if anybody can help insert the ROUND function into this vba code, or suggest a better way to wrap IFERROR to my selection and at the same time ROUND the data to 1 decimal place I would be very much obliged.
As a side I select cells B2:CE248 before running this so if it is more streamlined to state absolutly the cell range rather than applying to my higlighted selection then please feel free to ammed as apporpite. I am an absolute beginner with VBA.
To anybody who reads this, thank you for your time.
I would like some help please regarding VBA code. I have found some lines of code that work and add an IFERROR statement to whatever I have selected at the time on my worksheet, adding the text 'No Data' if there is an error. This works and I am happy with it. Here follows is the code:
Code:
Sub InsertIFERROR()
Dim R As Range
For Each R In Selection.SpecialCells(xlCellTypeFormulas)
R.Formula = "=IFERROR(" & Mid(R.Formula, 2) & ",""No Data"")"
Next R
End Sub
However I would like to add into this another formula which I have tried to do but my attempts lead to an error. The function I wish to add is the ROUND function which rounds the data to one decimal place e.g. on cell A1 it would be =ROUND(A1,1).
So if anybody can help insert the ROUND function into this vba code, or suggest a better way to wrap IFERROR to my selection and at the same time ROUND the data to 1 decimal place I would be very much obliged.
As a side I select cells B2:CE248 before running this so if it is more streamlined to state absolutly the cell range rather than applying to my higlighted selection then please feel free to ammed as apporpite. I am an absolute beginner with VBA.
To anybody who reads this, thank you for your time.