Looping concatenate based on input range

4fun123

New Member
Joined
Apr 17, 2022
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I need loop that would create concatenate from fixed values (strings) and loop it based on input range (dynamic, user input).

For example, "create image", input range 001-245, ".jpg", "image created", input range [same as 1st one].
Result would give create image 001.jpg image created 001

This is simplified sample as it would have multiple strings and input range would be.
Thanks!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
That is not enough information to do anything with. Use XL2BB to post a few rows of sample data and what you want the output to look like for each.

1650209783732.png
 
Upvote 0
Hello, thank you for answering, here is sheet explaining little better what i want (first 2 rows is how i want to "serve") 4-8th row are outputs of that. Cheers
example.JPG
 
Upvote 0
Posting your data as an image instead of using the XL2BB tool, you make it so that I would have to manually type in the above instead of just copy/paste it into my worksheet if I want play around with it.

1650235426487.png


Groceries.xlsx
ABCDE
1StorePriceQtyTotal
2Trader Joe$ 3.25Milk1$ 3.25
3Whole Foods$ 4.99Blueberries2$ 9.98
4Whole Foods$ 3.99Yogurt3$ 11.97
5Whole Foods$ 6.98Chicken1$ 6.98
6Safeway$ 6.00Apple Juice3$ 18.00
7$ 50.18
Sheet1
Cell Formulas
RangeFormula
E2:E6E2=B2*D2
E7E7=SUM(E2:E6)
 
Upvote 0
Posting your data as an image instead of using the XL2BB tool, you make it so that I would have to manually type in the above instead of just copy/paste it into my worksheet if I want play around with it.

View attachment 62676

Groceries.xlsx
ABCDE
1StorePriceQtyTotal
2Trader Joe$ 3.25Milk1$ 3.25
3Whole Foods$ 4.99Blueberries2$ 9.98
4Whole Foods$ 3.99Yogurt3$ 11.97
5Whole Foods$ 6.98Chicken1$ 6.98
6Safeway$ 6.00Apple Juice3$ 18.00
7$ 50.18
Sheet1
Cell Formulas
RangeFormula
E2:E6E2=B2*D2
E7E7=SUM(E2:E6)
Sorry about that, here is pasting in XL2bb, thanks!
Book3
ABCDEFGHI
1stringstrstrinputstrstrinputstrconcatenate
2createnewimage-101-104.jpgimage101-104created
3
4stringstrstrinputstrstrinputstrconcatenate
5create new image-101.jpg image 101 createdcreate new image-101.jpg image 101 created
6create new image-102.jpg image 102 createdcreate new image-102.jpg image 102 created
7create new image-103.jpg image 103 createdcreate new image-103.jpg image 103 created
8create new image-104.jpg image 104 createdcreate new image-104.jpg image 104 created
Sheet1
Cell Formulas
RangeFormula
I5:I8I5=CONCATENATE(A5,B5,C5,D5,E5,F5,G5,H5)
 
Upvote 0
Perhaps something like this

VBA Code:
Sub DoSomething()
    Dim WS As Worksheet
    Dim CellRange As Range, R As Range
    Dim I As Long, J As Long
    Dim S As String
    Dim SA As Variant
   
    Set WS = ActiveSheet

    Set CellRange = WS.Range("A2:I2")

    SA = Split(WS.Range("D2").Value, "-")

    J = 3
    With CellRange
        For I = Val(SA(0)) To Val(SA(1))
            .Copy .Offset(J)
            .Range("D1").Offset(J).Value = I
            .Range("G1").Offset(J).Value = I

            S = ""
            For Each R In .Offset(J)
                S = S & R.Value & " "
            Next R

            .Range("I1").Offset(J).Value = Replace(S, "- ", "-")
            J = J + 1
        Next I
    End With
End Sub
 
Upvote 0
Perhaps something like this

VBA Code:
Sub DoSomething()
    Dim WS As Worksheet
    Dim CellRange As Range, R As Range
    Dim I As Long, J As Long
    Dim S As String
    Dim SA As Variant
  
    Set WS = ActiveSheet

    Set CellRange = WS.Range("A2:I2")

    SA = Split(WS.Range("D2").Value, "-")

    J = 3
    With CellRange
        For I = Val(SA(0)) To Val(SA(1))
            .Copy .Offset(J)
            .Range("D1").Offset(J).Value = I
            .Range("G1").Offset(J).Value = I

            S = ""
            For Each R In .Offset(J)
                S = S & R.Value & " "
            Next R

            .Range("I1").Offset(J).Value = Replace(S, "- ", "-")
            J = J + 1
        Next I
    End With
End Sub
That's it! Thank you very very much.
Now i just need to take some time to understand some (not all of the code is clear for me completely) of it and im ready.
Cheers
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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