Why does my Excel Macro not work?

axeanddeer 1 Reputation point
2021-11-01T13:59:19.727+00:00

I am relatively new to Macros, so this code may look really bad.
What I am trying to do is:

I have a table with one column which looks like this:

I am text with a dot.
I am text without a dot
and I am also a text without a dot
so I want to be added.
I am a text with a dot.

The result should be:
I am text with a dot
I am text without a dot and I am also a text without a dot so I want to be added.

I am a text with a dot.

Meaning - All the cells below each other that do not have a dot should be summarized into one string, making the first cell the whole string and leaving the other cells blank.

What I tried is this, which simply results in Excel crashing:

Sub Rectify()

Dim Chain As String
Dim x As Integer
Dim y As Integer

x = 1

Do Until x > 5
Chain = Cells(x, "A").Value
y = x

Do Until Right(Cells(x, "A"), 1) = "."
    Chain = Chain + " " + Cells(x, 1).Value
    Cells(x, "A") = " "
    x = x + 1
Loop

Loop

End Sub

I come from a different programming language and am rusty - I hope someone can help me make it work.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
1,977 questions
No comments
{count} votes