Vba range modification

SGT_Spittal

New Member
Joined
Dec 10, 2015
Messages
10
I'm looking for a bit of help with the following code which I got from How to add a range of cells in excel – concat() | Chandoo.org - Learn Microsoft Excel Online

i want to modify this function based on the table below.

as you can see from the function you select a range and optional delimiter and it collates the range to one cell.

I want to modify this so that the selected range is bassed on the cell in column A

Example

In cell K2 I put the formulae =CONCAT(A2," ") but the formulae will look at the range C2:F4

[h=1]Function concat(useThis As Range, Optional delim As String) As String[/h]
<code style="margin: 0px; padding: 0px; border: none;">' this function will concatenate a range of cells and return one string
' useful when you have a rather large range of cells that you need to add up
Dim retVal, dlm As String
retVal = ""
If delim = Null Then
dlm = ""
Else
dlm = delim
End If
For Each cell In useThis
if cstr(cell.value)<>"" and cstr(cell.value)<>" " then
retVal = retVal & cstr(cell.Value) & dlm
end if
Next
If dlm <> "" Then
retVal = Left(retVal, Len(retVal) - Len(dlm))
End If
concat = retVal
End Function


</code>

ABCDEFGHIJKL
1Design ZoneCompartment No.EQ'sCR'sEQ's 1CR's 1
205DZ766200900, 201059, 201193, 201222, =CONCAT(C2)=CONCAT(G2:J4)
3201237, 201253, 201280, 201323,
4201360
505DZ060T26-DDI000059, T26-EIS000543, T26-EIS000741, T26-EIS000743, 200521, 200669, 200741, 200745, =CONCAT(C5:F18)=CONCAT(G5:J18)
6T26-EIS000833, T26-EIS000966, T26-EIS000976, T26-EIS001302, 200787, 200789, 200824, 200857,
7T26-EIS001314, T26-EIS001315, T26-EIS001316, T26-EIS001318, 200870, 200898, 200900, 200917,
8T26-EIS001357200920, 200926, 200929, 200933,
9200944, 200989, 200997, 201019,
10201056, 201059, 201060, 201085,
11201092, 201102, 201117, 201119,
12201128, 201140, 201193, 201197,
13201199, 201222, 201237, 201253,
14201266, 201268, 201280, 201281,
15201287, 201323, 201328, 201341,
16201346, 201351, 201359, 201362,
17201374, 201396, 201422, 201495,
18 201508, 201521, 201534
1905DZ061 200944, 201422
2005DZ063T26-DDI000079, T26-EIS000274, T26-EIS000543, T26-EIS000622, 200604, 200669, 200682, 200741,
21T26-EIS000741, T26-EIS000743, T26-EIS000846, T26-EIS000895, 200779, 200789, 200882, 200898,
22T26-EIS000976200905, 200922, 200939, 200944,
23200997, 200998, 201004, 201019,
24201054, 201060, 201085, 201092,
25201113, 201117, 201119, 201139,
26201140, 201161, 201165, 201174,
27201193, 201237, 201266, 201280,
28201323, 201336, 201351, 201361,
29 201410, 201508, 201521, 201532
3005DZ063T26-DDI000079, T26-EIS000274, T26-EIS000543, T26-EIS000622, 200604, 200669, 200682, 200741,
31T26-EIS000741, T26-EIS000743, T26-EIS000846, T26-EIS000895, 200779, 200789, 200882, 200898,
32T26-EIS000976200905, 200922, 200939, 200944,
33200997, 200998, 201004, 201019,
34201054, 201060, 201085, 201092,
35201113, 201117, 201119, 201139,
36201140, 201161, 201165, 201174,
37201193, 201237, 201266, 201280,
38201323, 201336, 201351, 201361,
39 201410, 201508, 201521, 201532

<colgroup><col><col span="12"></colgroup><tbody>
</tbody>
<code style="margin: 0px; padding: 0px; border: none;">
</code>
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
ABCDEFGHIJKL
1Design ZoneCompartment No.EQ'sCR'sEQ's 1CR's 1
205DZ766 200900, 201059, 201193, 201222, =CONCAT(C2:F4)=CONCAT(G2:J4)
3201237, 201253, 201280, 201323,
4201360
505DZ060T26-DDI000059, T26-EIS000543, T26-EIS000741, T26-EIS000743, 200521, 200669, 200741, 200745, =CONCAT(C5:F18)=CONCAT(G5:J18)
6T26-EIS000833, T26-EIS000966, T26-EIS000976, T26-EIS001302, 200787, 200789, 200824, 200857,
7T26-EIS001314, T26-EIS001315, T26-EIS001316, T26-EIS001318, 200870, 200898, 200900, 200917,
8T26-EIS001357 200920, 200926, 200929, 200933,
9 200944, 200989, 200997, 201019,
10 201056, 201059, 201060, 201085,
11 201092, 201102, 201117, 201119,
12 201128, 201140, 201193, 201197,
13 201199, 201222, 201237, 201253,
14 201266, 201268, 201280, 201281,
15 201287, 201323, 201328, 201341,
16 201346, 201351, 201359, 201362,
17 201374, 201396, 201422, 201495,
18 201508, 201521, 201534
1905DZ061 200944, 201422
2005DZ063T26-DDI000079, T26-EIS000274, T26-EIS000543, T26-EIS000622, 200604, 200669, 200682, 200741,
21T26-EIS000741, T26-EIS000743, T26-EIS000846, T26-EIS000895, 200779, 200789, 200882, 200898,
22T26-EIS000976 200905, 200922, 200939, 200944,
23 200997, 200998, 201004, 201019,
24 201054, 201060, 201085, 201092,
25 201113, 201117, 201119, 201139,
26 201140, 201161, 201165, 201174,
27 201193, 201237, 201266, 201280,
28 201323, 201336, 201351, 201361,
29 201410, 201508, 201521, 201532
3005DZ063T26-DDI000079, T26-EIS000274, T26-EIS000543, T26-EIS000622, 200604, 200669, 200682, 200741,
31T26-EIS000741, T26-EIS000743, T26-EIS000846, T26-EIS000895, 200779, 200789, 200882, 200898,
32T26-EIS000976 200905, 200922, 200939, 200944,
33 200997, 200998, 201004, 201019,
34 201054, 201060, 201085, 201092,
35 201113, 201117, 201119, 201139,
36 201140, 201161, 201165, 201174,
37 201193, 201237, 201266, 201280,
38 201323, 201336, 201351, 201361,
39 201410, 201508, 201521, 201532

<colgroup><col><col span="12"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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