make number series in excel visual basic

I need excel visual basic macros that would make for me series of numbers that looks like



4.5,      5, 5.5, 6, 6.5, 7, 7.5 , 8, 8.5, 9, 9.5 ...  in single sell

the comma is obligatory

So I simple button "start " ; input cells and output cell
In attachment you can find an example of sheet design
numbers.xlsx
SunnyXAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
Will this do?
Option Explicit

Sub MakeNumbersString()
    Dim s As Single
    Dim strNumbers As String
    
    s = Cells(3, 3).Value
    Do Until s >= Cells(5, 3)
        s = s + 0.5
    
        strNumbers = strNumbers & s & ", "
    Loop
    strNumbers = Left(strNumbers, Len(strNumbers) - 2)
    Cells(8, 8) = strNumbers
End Sub

Open in new window

0
GrahamSkanRetiredCommented:
Oops. No it won't. The first number has been omitted.
0
Saurabh Singh TeotiaCommented:
Their you go i wrote a udf for you which does what you are looking for..

Function getsrs(r As Range, r1 As Range)

Application.Volatile
    Dim k As Double, z As Double
    Dim i As Double, str As String

    k = r.Value
    z = r1.Value

    For i = k To z Step 0.5

        If str = "" Then
            str = i
        Else
            str = str & " , " & i
        End If

    Next i


    getsrs = str
End Function

Open in new window


Saurabh...
numbers.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GrahamSkanRetiredCommented:
But easily fixed:
Sub MakeNumbersString()
    Dim s As Single
    Dim strNumbers As String
    
    s = Cells(3, 3).Value
    strNumbers = s & ", "
    Do Until s >= Cells(5, 3)
        s = s + 0.5
        strNumbers = strNumbers & s & ", "
    Loop
    strNumbers = Left(strNumbers, Len(strNumbers) - 2)
    Cells(8, 8) = strNumbers
End Sub

Open in new window

0
Saqib Husain, SyedEngineerCommented:
Sub halvesseries()
    Dim i As Integer
    Dim sstr As String
    For i = Range("c3").Value * 2 To Range("c5").Value * 2
        sstr = sstr & IIf(sstr = "", "", ", ") & i / 2
    Next i
    [h8] = sstr
End Sub
0
Rory ArchibaldCommented:
Just for fun:

Sub foo()
    Range("H8").Value = Join(Filter(Evaluate("Transpose(IF(MOD(ROW(" & Range("C3").Value * 10 & ":" & Range("C5").Value * 10 & "),5)=0,ROW(" & Range("C3").Value * 10 & ":" & Range("C5").Value * 10 & ")/10,""|""))"), "|", False), ",")
End Sub

Open in new window


I would never recommend using it though. :)
0
ProfessorJimJamCommented:
Rory :-D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.