combine number and string

G

Guest

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

Guest

Does this do what you want?

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


Mike
 
R

Rick Rothstein \(MVP - VB\)

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
 
G

Guest

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

John

Don't you have to get a string version of the number to combine it with
a string? Str(A1) instead of A1.

john
 

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

Top