-1

如何比较excel vba中的字符串值?例如 texbox1.text = A 和 textbox2.text = AAA,所以 texbox1.text < textbox2.text 因此 msgbox 将显示 A < AAA。如何做到这一点?

4

1 回答 1

0

Are the textbox strings in reference to Columns?

If so, you just need one If statement to check the condition:

Untested

If Columns(textbox1.Text).Column < Columns(textbox2.Text).Column Then
    Msgbox "" & UCase(textbox1.Text) & "<" & UCase(textbox2.Text) & ""
End If

You'd need to add some error handling though to handle situations where the text didn't match a column reference.

Also, if this is in reference to columns, in Excel 2010 the maximum column is XFD or column number 16,384...

于 2013-11-09T16:54:35.823 回答