PC Review


Reply
Thread Tools Rate Thread

combine number and string

 
 
=?Utf-8?B?ZXppbA==?=
Guest
Posts: n/a
 
      6th Jul 2007
I have numeric data in column a and i add this data with a string in column b
for
specified range. For that if I typed formula as follows and copy the formula
to group of
cells it is working. But if write the same formula in a macro it is not
working.
How to combine text and number for group of cells through macro?

a1= 3
b1=a1&"s" (3s)
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      6th Jul 2007
Does this do what you want?

Sub peraltive()
myNewvalue = Cells(1, 1).Value & Cells(1, 2).Value
End Sub


Mike

"ezil" wrote:

> I have numeric data in column a and i add this data with a string in column b
> for
> specified range. For that if I typed formula as follows and copy the formula
> to group of
> cells it is working. But if write the same formula in a macro it is not
> working.
> How to combine text and number for group of cells through macro?
>
> a1= 3
> b1=a1&"s" (3s)

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Jul 2007
>I have numeric data in column a and i add this data with a string in column
>b
> for
> specified range. For that if I typed formula as follows and copy the
> formula
> to group of
> cells it is working. But if write the same formula in a macro it is not
> working.
> How to combine text and number for group of cells through macro?
>
> a1= 3
> b1=a1&"s" (3s)


In the 2nd statement, put a space between a1 and the ampersand...

b1 = a1 & "s"

I think the problem is the ampersand is a variable type declaration symbol
in VB, so VB's parser apparently thinks you want the variable a1& which
means (to it) you have no operator between that variable and what follows
it.

Rick

 
Reply With Quote
 
=?Utf-8?B?ZXppbA==?=
Guest
Posts: n/a
 
      6th Jul 2007
My requirement is for group of cells. I write the following code in macro but
it
gives error message.
Range(Cells(1, 2), Cells(10, 2)).Formula = "=A1&"s""
the other formula also gives error message
Range(Cells(1, 2), Cells(10, 2)).Formula = "=CONCATENATE(a1,"s")
(where a1 value is numeric)
"Mike H" wrote:

> Does this do what you want?
>
> Sub peraltive()
> myNewvalue = Cells(1, 1).Value & Cells(1, 2).Value
> End Sub
>
>
> Mike
>
> "ezil" wrote:
>
> > I have numeric data in column a and i add this data with a string in column b
> > for
> > specified range. For that if I typed formula as follows and copy the formula
> > to group of
> > cells it is working. But if write the same formula in a macro it is not
> > working.
> > How to combine text and number for group of cells through macro?
> >
> > a1= 3
> > b1=a1&"s" (3s)

 
Reply With Quote
 
John
Guest
Posts: n/a
 
      7th Jul 2007
Don't you have to get a string version of the number to combine it with
a string? Str(A1) instead of A1.

john

ezil wrote:

> My requirement is for group of cells. I write the following code in macro but
> it
> gives error message.
> Range(Cells(1, 2), Cells(10, 2)).Formula = "=A1&"s""
> the other formula also gives error message
> Range(Cells(1, 2), Cells(10, 2)).Formula = "=CONCATENATE(a1,"s")
> (where a1 value is numeric)
> "Mike H" wrote:
>
>
>>Does this do what you want?
>>
>>Sub peraltive()
>> myNewvalue = Cells(1, 1).Value & Cells(1, 2).Value
>>End Sub
>>
>>
>>Mike
>>
>>"ezil" wrote:
>>
>>
>>>I have numeric data in column a and i add this data with a string in column b
>>>for
>>>specified range. For that if I typed formula as follows and copy the formula
>>>to group of
>>>cells it is working. But if write the same formula in a macro it is not
>>>working.
>>>How to combine text and number for group of cells through macro?
>>>
>>>a1= 3
>>>b1=a1&"s" (3s)

 
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
combine string Newbie Microsoft Access 3 29th Sep 2008 01:15 PM
Change 3 letter text string to a number string Pete Microsoft Excel Misc 3 31st Dec 2007 07:47 PM
How to combine search patterns in DirectoryInfo.GetFiles(string searchPattern) deerchao Microsoft C# .NET 1 6th Aug 2007 08:45 AM
Combine Strings into One String =?Utf-8?B?QWRhbQ==?= Microsoft Excel Programming 3 9th Mar 2005 09:09 AM
how do i combine a number and a string? plus increment.... =?Utf-8?B?bmlja2xhdXM=?= Microsoft Access 2 26th Feb 2005 05:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:29 PM.