No announcement yet.

Unconfigured Ad Widget


VBA: Delete the first two characters of a cell

  • Filter
  • Time
  • Show
Clear All
new posts

  • VBA: Delete the first two characters of a cell

    I have a set of data that is about 27000 cells long. How do I write a macro that selects a column of data and deletes the first two characters.

    Any help would be greatly appreciated.

  • #2
    A macro can be done, but it might be safer to enter the following in a blank row 1 cell of an adjacent column to the right (or a newly created blank column) the following: assuming the original data are in column A:


    Then autofill column B by doubled clicking on the small dark square at the bottom right of cell B1 when it is selected. This should autofill column B to the end of Column A entries (assuming they are contiguous) and also leave the column B cells selected. Copy the column B cells and the do a PASTE SPECIAL > VALUES (either in place in column B or over the top of the original data in column A. This should create a new dataset that is minus the first two characters.

    If you still need or want a macro to do this, see the attached. But be warned that the macro will do exactly what you ask -- remove the first two characters from each cell in column A. If you run it a second time, the next two characters will be gone, too. If someone runs it "for" you a week later, an additional two characters will disappear.

    Having a macro around that can do inadvertant harm always bothers me.
    Best Regards,
    Please help Oz share knowledge among all users by posting your questions in a public forum rather than using a Private Message.




    There are no results that meet this criteria.