display consecutive values vba export text

biq3468

New Member
Joined
Aug 27, 2014
Messages
2
Hello,
I am new to Excel VBA, I work as an engineer and use a lot of data in Excel.
I wish I could simplify some of the work by opening this thread.
This may be very simple, but I can't seem to find a way.
Given a column, or a cell with values like :
F001
F002
F003
F004
F017
F020
F021
F121
F122
F123
...
I need a text result in a cell or in a message box to arrange this data into consecutive values, something like this:
"F001 to F004,F017, F020 to F021, F121 to F123 ..."
This text will be then used in other software by paste.
Hope you understand what Im asking.
Thank you very much!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try this:
Code:
=A1&A2&A3&A4

Or if you want the commas also:

Code:
=A1&","&A2&","&A3
 
Last edited:
Upvote 0
If you want a script tell me what column and row number your data begins in and what cell you want the results put in. And how many rows of data you have. Later you can modify this to your liking.
 
Upvote 0
Hy
Thank you for your help.
I only use one column at a time, so it does not matter.
The only variable is the number of values. The result can be displayed anywhere, so B1 should be just fine.
My only request is to have result in only one cell and with the word "to" in between consecutive.
Thank you!
 
Upvote 0
Putting the word "Two" between consecutive numbers is beyond my knowledge base. Someone else may chime in on this thread.</SPAN>
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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