ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Concatenate function in vba (https://www.excelbanter.com/new-users-excel/30316-concatenate-function-vba.html)

camerons

Concatenate function in vba
 
I am trying to do the following:

Sub Sample()
For a = 1 To 100
r = concatenate(Cells(a, 1), Cells(a, 2))
If r = "Mr.Jones" Then
Cells(a, 3) = ""
End If
Next a
End Sub

There is more to it, but I can't seem to use the concatenate function.
"Left", "Right" are ok, but not this one it seems. What am I missing?

Thank you
Chris Cameron




JMB

you have to use the "&"

= Cells(a, 1) & Cells(a, 2)


"camerons" wrote:

I am trying to do the following:

Sub Sample()
For a = 1 To 100
r = concatenate(Cells(a, 1), Cells(a, 2))
If r = "Mr.Jones" Then
Cells(a, 3) = ""
End If
Next a
End Sub

There is more to it, but I can't seem to use the concatenate function.
"Left", "Right" are ok, but not this one it seems. What am I missing?

Thank you
Chris Cameron





JE McGimpsey

One way:

Dim a As Long
For a = 1 To 100
If Cells(a, 1).Text & Cells(a, 2).Text = "Mr.Jones" Then _
Cells(a, 3).ClearContents
Next a


In article ,
"camerons" wrote:

I am trying to do the following:

Sub Sample()
For a = 1 To 100
r = concatenate(Cells(a, 1), Cells(a, 2))
If r = "Mr.Jones" Then
Cells(a, 3) = ""
End If
Next a
End Sub

There is more to it, but I can't seem to use the concatenate function.
"Left", "Right" are ok, but not this one it seems. What am I missing?

Thank you
Chris Cameron


camerons

Thanks, I've got it working now.
What would you suggest for learning correct syntax for VBA?






All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com