• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to combine two cells

Hi All,


I need your help to concatenate two cells values through macro.


Below are the values:


A(Column) B (Column) C(Column)Need help on this column

123456 1 123456.01

123457 15 123456.15


I need the values in column "C"


Regards,

Sattt...
 
Sattt...


Why do you need a macro ?

In Column C assuming Row 2 put =A2&B2
 
Rather than using a macro, you could use formula:

=A1+B1/100

If you really want a macro:

[pre]
Code:
Sub BuildValue()
Dim LastRow As Long
Dim i As Long

With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

If LastRow < 2 Then Exit Sub 'Nothing exists

Application.ScreenUpdating = False
For i = 2 To LastRow
.Cells(i, "C") = .Cells(i, "A").Value + .Cells(i, "B").Value / 100
Next
End With
Application.ScreenUpdating = False

End Sub
[/pre]
 
Hi Luke & Hui,


Thanks for your response on this.


Luke sorry for the confusion i wanted to concatenate A & B column values like below


A Column = 123456

B Column = 1

I would like to combine both A & B Column values in "C" = 123456.01 (formula= A+&"."&"0"&B

if suppose in B Column value is lessthan 2 digits (ex:1,2,3..9) while combining it should start with 0 or the value is equal to 2 digits (ex: 11,12,13...99) 0 is not required.


Please suggest.


Regards,

Sattt
 
Satish,


Although a different approach, I'm not sure why diving by 100 doesn't work. From the examples you gave, the end result is the same.
 
Ah, okay. Glad it worked out! I was scratching my head there for a bit trying to figure out what I was missing. =P
 
Back
Top