concatenate with vba

  • Thread starter Thread starter Maxi
  • Start date Start date
M

Maxi

Hi!

I have first name in A1 and last name in A2

When I use the syntax
Sheets("Extract").Range("A" & ERow).Value = ActiveCell.Offset(0,
-2).Value & ActiveCell.Offset(0, -3).Value

Value of ERow is 1
Offset -2 is the first name
Offset -3 is the last name

VBA does not support "&" to get both the names in one cell of a
different sheet?

Please help
 
I bet that the activecell isn't what you think it should be.

Maybe adding:
msgbox activecell.address(external:=true)
to your code will help you debug the problem.
 
maybe not the ideal way, but

Declare 2 variables

Set Var1 = ActiveCell.Offset(0,-2)
Set VAr2 = ActiveCell.Offset(0,-3)

Sheets("Exrtract").Range("A" & ERow) = Var1 & Var2


HTH
 
Thanx Steve, it worked

One more question. How do I remove the last character of var2
variable?

For instance:
var1 has Justin
var2 has Kemp,

I need only Justin Kemp after concatenation.

Thanx
 
VBA does not support "&" to get both the names in one cell of a
different sheet?

Yes, it does. However, your code will fail if ActiveCell is in columns
A-C, because it can't go 3 columns left.

Are you getting an error message? If so, what kind?

Hth,
Merjet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top