Help to change code from add value to combine

sbv1986

Board Regular
Joined
Nov 2, 2017
Messages
87
Hi all

Hi have code belove will adding value (like =sum) from multiple sheet to master
But now I all value will be combine (not add), so please help me change code to do that

thanks./.


Code:
[COLOR=#141414][FONT=inherit]For Each k In .SelectedItems[/FONT][/COLOR]<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">        Set Wb = Workbooks.Open(k)
        arr1 = Wb.Sheets("PL1").Range("C9:I57").Value
        arr2 = Wb.Sheets("PL2").Range("C9:v81").Value
        arr3 = Wb.Sheets("PL3").Range("C9:AU81").Value
        Wb.Close False
        
        For i = 1 To UBound(arr1, 1)
            For j = 1 To UBound(arr1, 2)
               If arr1(i, j) <> Empty And IsNumeric(arr1(i, j)) = True Then
                dArr1(i, j) = dArr1(i, j) + arr1(i, j)
               End If
            Next j
        Next i
        
        For i = 1 To UBound(arr2, 1)
            For j = 1 To UBound(arr2, 2)
               If arr2(i, j) <> Empty And IsNumeric(arr2(i, j)) = True Then
                dArr2(i, j) = dArr3(i, j) + arr2(i, j)
               End If
            Next j
        Next i
       
        For i = 1 To UBound(arr3, 1)
            For j = 1 To UBound(arr3, 2)
               If arr3(i, j) <> Empty And IsNumeric(arr3(i, j)) = True Then
                dArr3(i, j) = dArr3(i, j) + arr3(i, j)
               End If
            Next j
        Next i
    Next
    End With
    Sheets("PL1").Range("C9:I57").Value = dArr1
    Sheets("PL2").Range("C9:v81").Value = dArr2 </code>[COLOR=#141414][FONT=inherit]    Sheets("PL3").Range("C9:AU81").Value = dArr3[/FONT][/COLOR]
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If you want the values to be combined in a string instead of added, change the addition lines (like these):
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; font-family: inherit; line-height: 12px; box-sizing: border-box; font-size: 1em;">dArr1(i, j) = dArr1(i, j) + arr1(i, j)</code>
to something like this:
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; font-family: inherit; line-height: 12px; box-sizing: border-box; font-size: 1em;">dArr1(i, j) = dArr1(i, j) & arr1(i, j)</code>

Note that if you want commas and spaces between each entry, you can do something like this instead:
Code:
<code style="font-size: 1em; font-style: inherit; font-weight: inherit; margin: 0px; padding: 0px; font-family: inherit; line-height: 12px; box-sizing: border-box;">dArr1(i, j) = dArr1(i, j) & ", " & arr1(i, j)</code>
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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