0

On Excel 2010, I have some spectaculars bugs after a conditional formating :

Before:

enter image description here

After:

enter image description here or like that (depends...) : enter image description here

And without bug it could be like that :

enter image description here

I'm more or less sure that is an Excel bug caused by my personal formula in VBA:

Function NumCol(plage As Range, ch As String) As Long

    'Application.Volatile

    For Each c In plage
        If c.Value = ch Then NumCol = c.Column
    Next

End Function


Function NumLig(plage As Range, ch As String) As Long

    'Application.Volatile

    For Each c In plage
        If c.Value = ch Then NumLig = c.Row
    Next

End Function

What can I do to correct this visual bug ?

1 Answer 1

1

Please try

c.HorizontalAlignment = xlCenter 
c.VerticalAlignment = xlCenter

in each loop.

Sign up to request clarification or add additional context in comments.

4 Comments

@QuentinT. Is it merged cells?
Yes, merged cells. Sorry it's my bad, it's working well now (I had missed c.VerticalAlignment = xlCenter...). But I have another bug, when I do an alt+tab on the file, it break again the visual...
Try add Application.ScreenUpdating = False on start in your function and add Application.ScreenUpdating = True at the end.
And the same with Application.ScreenUpdating true or false... The visual format and bugs appears more or less randomly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.