Hmm, your logic and actual grouping is in conflict...
Basically, what you are trying to do is set up Bin with variable container range (Frequency Distribution).
Fuzzy logic like what you have done in actual grouping is bit tricky/difficult to do with VBA. Unless the logic can be expressed mathematically.
If it's fixed range which is set at start of operation (say 2, 3, 4 or some other number), it will be much simpler.
I'd suggest you upload few different data set and what grouping you'd like to see for each.
As I'd imagine grouping will change drastically depending on sample distribution range.
Edit: You might find following link helpful (using fixed calculated Bin size)
Dynamic Histogram/Frequency Distribution Chart
https://www.excelcampus.com/charts/dynamic-histogram/
Bookmarks