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
RequestLI
1375240810
3003171640
3003678220
3003149210
1646890210

<colgroup><col style="text-align: center;"><col style="text-align: center;"></colgroup><tbody>
</tbody>

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


ABC
1RequestLIConcentrate
213752408101375240810
330031716403003171640
430036782203003678220
530031492103003149210
616468902101646890210

<colgroup><col><col><col></colgroup><tbody>
</tbody>
etc..


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

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,215,108
Messages
6,123,132
Members
449,098
Latest member
Doanvanhieu

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