i want to do this thru VBA , auto concentrate two (columns ) numbers to one (column ) number

alstudent

New Member
Joined
Feb 4, 2016
Messages
3
Hello everyone,

i really need your help ..
i am daily adding data like this into my daily report

RAW DOWNLOADED FROM SAP
[TABLE="width: 132"]
<colgroup><col style="text-align: center;"><col style="text-align: center;"></colgroup><tbody>[TR]
[TD]Request[/TD]
[TD="align: center"]LI[/TD]
[/TR]
[TR]
[TD="align: center"]13752408[/TD]
[TD="align: center"]10[/TD]
[/TR]
[TR]
[TD="align: center"]30031716[/TD]
[TD="align: center"]40[/TD]
[/TR]
[TR]
[TD="align: center"]30036782[/TD]
[TD="align: center"]20[/TD]
[/TR]
[TR]
[TD="align: center"]30031492[/TD]
[TD="align: center"]10[/TD]
[/TR]
[TR]
[TD="align: center"]16468902[/TD]
[TD="align: center"]10[/TD]
[/TR]
</tbody>[/TABLE]

i wanted it to be automatically like this .. thru VBA .. once i paste it ..


[TABLE="width: 213"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Request[/TD]
[TD="align: center"]LI[/TD]
[TD="align: center"]Concentrate[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD="align: center"]13752408[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]1375240810[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD="align: center"]30031716[/TD]
[TD="align: center"]40[/TD]
[TD="align: center"]3003171640[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD="align: center"]30036782[/TD]
[TD="align: center"]20[/TD]
[TD="align: center"]3003678220[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD="align: center"]30031492[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]3003149210[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD="align: center"]16468902[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]1646890210[/TD]
[/TR]
</tbody>[/TABLE]
etc..


if you know one automated way to do this thru VBA , it will support me a lot
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Code:
Sub ConcatenateColumns()
    Dim lastRow As Long, r As Long
    lastRow = Cells(Rows.Count, 1).End(xlUp).Row
    For r = 2 To lastRow
        Range("C" & r).Value = Range("A" & r).Value & Range("B" & r).Value
    Next r
End Sub

this should work
 
Last edited:
Upvote 0
Welcome to the Board!

Here's a way to do it with no loops (usually faster to avoid loops, when possible):
Code:
Sub CombineData()

    Dim lRow As Long
    
'   Find last row with data in column A
    lRow = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Apply formula to column C from row 2 to end
    Range("C2:C" & lRow).FormulaR1C1 = "=RC[-2]&RC[-1]"
'   Change to hard-coded values
    Range("C2:C" & lRow).Value = Range("C2:C" & lRow).Value
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top