Learn how to a build a cloud-first strategyRegister Now


help with excel macro.

Posted on 2011-05-04
Medium Priority
Last Modified: 2012-05-11
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.

Question by:koala-london
  • 3

Author Comment

ID: 35695847
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.
LVL 23

Accepted Solution

Brian Gee earned 2000 total points
ID: 35695911
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


Author Comment

ID: 35695960
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.

Author Closing Comment

ID: 35695965
the answer is spot on. thanks

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question