I’m trying to write a macro that finds empty cells in a selection and replaces them with 0 (zero).
I’m pretty much there, I have a macro that loops the selection and finds empty cells, the problem I have is all I can find to do the find & replace is ReplaceDescriptor, the ReplaceDescriptor.ReplaceString is, of course, a string. I can’t find much in the way of properties, methods etc. Is there a ReplaceDescriptor.ReplaceString numeric equivalent or am I trying to convert it wrong? (which I’ve given up with as it doesn’t like any conversion methods I’ve tried!)
I probably don’t need an input box but it makes the macro less restricted.
This is what I have so far;
Dim Doc As Object
Dim Sheet As Object
Dim oRange As Object
Dim ReplaceDescriptor As Object
Dim I As Integer
Dim InputValue As Integer
Doc = ThisComponent
Sheet = Doc.Sheets(0)
oRange = Doc.currentselection
InputValue = CInt(InputBox("Enter value that will fill empty cells in selection", _
"Fill Empty Cells"))
ReplaceDescriptor = Sheet.createReplaceDescriptor()
ReplaceDescriptor.SearchString = ""
ReplaceDescriptor.ReplaceString = InputValue
For I = 0 to Doc.Sheets.Count - 1
Sheet = Doc.Sheets(I)
oRange.ReplaceAll(ReplaceDescriptor)
Next I