Jon_London
New Member
- Joined
- Jan 24, 2019
- Messages
- 12
- Office Version
- 365
Hello everyone,
I'm VERY new to VBA and am trying to achieve the following outcome:
I would like a range of cells (e.g. E1:E5) to be concatenated with CP-0001;, CP-0002; and CP-0003;. So, if the contents of cell E1 is 12345 I would like the output to be CP-0001;12345, CP-0002;12345 and CP-0003;12345 on three separate rows in my spreadsheet. The code should then look at cell E2 and repeat the process.
I've tried my very rudimentary code below, but it obviously doesn't work! Could anyone please help me?
Sub vba_concatenate()
Range("A1,A100") = "CP-0001;" & Range("E1,E100")
Range("A1,A100") = "CP-0002;" & Range("E1,E100")
Range("A1,A100") = "CP-0003;" & Range("E1,E100")
End Sub
Many thanks
Jon
I'm VERY new to VBA and am trying to achieve the following outcome:
I would like a range of cells (e.g. E1:E5) to be concatenated with CP-0001;, CP-0002; and CP-0003;. So, if the contents of cell E1 is 12345 I would like the output to be CP-0001;12345, CP-0002;12345 and CP-0003;12345 on three separate rows in my spreadsheet. The code should then look at cell E2 and repeat the process.
I've tried my very rudimentary code below, but it obviously doesn't work! Could anyone please help me?
Sub vba_concatenate()
Range("A1,A100") = "CP-0001;" & Range("E1,E100")
Range("A1,A100") = "CP-0002;" & Range("E1,E100")
Range("A1,A100") = "CP-0003;" & Range("E1,E100")
End Sub
Many thanks
Jon