GetFormat converts the referenced cell format to text. This code was taken from here. I changed it to use NumberFormatLocal as NumberFormat wasn’t producing the expected results e.g. where I was expecting #,##0;[Red]-#,##0, GetFormat was returning #,##0_);[Red](#,##0)
Function GetFormat(Cell as Range) as String GetFormat = cell.NumberFormatLocal End Function
How to use:
- Copy code.
- Open workbook to copy code to.
- In Excel, press Alt + F11 to open the VIsual Basic Editor (VBE).
- Click the Insert menu.
- Click Module.
- Paste code in right window.
- Press Alt + Q to close the VBE.