help with excel macro.

Hi there,

I need to write a macro on excel when user press the button, I need to put  "-X" to the end of the data on Column F.

I have no idea on how to do it for the user in quickest manner. I really need your help guys.

Who is Participating?
Brian GeeCommented:
Try this code:

Sub AddX()

    Dim Num As Integer
    Dim Cell As String
    Num = 1
    Cell = "F" & 1
    Do Until Range(Cell).Value = ""
        If Range(Cell).Value <> "" Then
            Range(Cell).Value = Range(Cell).Value & "-X"
            Num = Num + 1
            Cell = "F" & Num
        End If
End Sub

Open in new window

koala-londonAuthor Commented:
I mean I need to append the data "-X" to the end of the cell on column F.

might have to create loop where we don't know how long the column will be.
koala-londonAuthor Commented:
This perfectly works as i want. But i want to trigger it from button. i will close it and open it new question for you as it is another topics.


Please help me how to trigger it from button.
koala-londonAuthor Commented:
the answer is spot on. thanks
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.

All Courses

From novice to tech pro — start learning today.