2

I have a UserForm that automatically populates with given data from a table, I cannot get the format of the date to change. I am not sure where my code went wrong.

Set name_ = Display.Controls.Add("Forms.Label.1", "Test" & labelCounter, True)
    With name_
        .Caption = Format(debt_name_cell, mmm - yy)
        .Left = 10
        .Width = 50
        .Top = 10 * labelCounter
    End With
    Set debt_name_cell = debt_name_cell.Offset(1, 0)

The result is always:

0

1 Answer 1

3

Having a look at the Microsoft VBA Reference is always a good idea:
Format Function (Visual Basic for Applications).

There we can see that the second parameter of the Format function has to be a string like

Format(debt_name_cell, "mmm - yy")

If you follow VBA Best Practices use Option Explicit at the top of every VBA module you would have recognized an issues like that in a second!

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

1 Comment

If this answer helped you, please consider accepting it. Accepting an answer rewards the contributor for their time and helps others to find a workling solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.