question

axeanddeer-0561 avatar image
0 Votes"
axeanddeer-0561 asked

Why does my Excel Macro not work?

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-vba-devoffice-scripts-excel-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers