vba concatenate strings and integer

To concatenate strings and integers in VBA, you can use the & operator. Here's an example:

Dim str As String
Dim num As Integer

str = "Hello"
num = 123

str = str & " " & CStr(num)

MsgBox str

In this example, the & operator is used to concatenate the string "Hello" with a space and the converted integer value. The CStr function is used to convert the integer to a string before concatenation.

The resulting string will be displayed in a message box as "Hello 123".

Please note that the & operator can also be used to concatenate other data types, such as dates or floating-point numbers, with strings in VBA.