PC Review


Reply
Thread Tools Rate Thread

concatenate with vba

 
 
Maxi
Guest
Posts: n/a
 
      2nd Jul 2007
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

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Jul 2007
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.

Maxi wrote:
>
> 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


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?c3RldmVfZG9j?=
Guest
Posts: n/a
 
      2nd Jul 2007
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

"Maxi" wrote:

> 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
>
>

 
Reply With Quote
 
Maxi
Guest
Posts: n/a
 
      2nd Jul 2007
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

On Jul 2, 8:42 pm, steve_doc <steve...@discussions.microsoft.com>
wrote:
> 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
>
>
>
> "Maxi" wrote:
> > 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- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      2nd Jul 2007
> 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



 
Reply With Quote
 
Maxi
Guest
Posts: n/a
 
      2nd Jul 2007
I was able to remove the last character... Thanx for your help

On Jul 2, 8:48 pm, Maxi <maheshchindar...@gmail.com> wrote:
> 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
>
> On Jul 2, 8:42 pm, steve_doc <steve...@discussions.microsoft.com>
> wrote:
>
>
>
> > 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

>
> > "Maxi" wrote:
> > > 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- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate =?Utf-8?B?Sm9yZGFu?= Microsoft Excel Worksheet Functions 3 23rd Feb 2006 11:59 PM
I know how to concatenate ,can one de-concatenate to split date? =?Utf-8?B?UVVJQ0sgQk9PS1MgUFJPQkxFTS0=?= Microsoft Excel New Users 1 26th Jul 2005 05:07 PM
concatenate john Microsoft Access 3 4th Aug 2004 09:59 PM
CONCATENATE lehigh@nni.com Microsoft Excel Worksheet Functions 1 7th Oct 2003 01:58 PM
Concatenate Pam Microsoft Excel Worksheet Functions 3 29th Aug 2003 03:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:26 AM.