×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

excel macro

excel macro

excel macro

(OP)
I have an excel file I import. It is a database with 600+ records. After I import one field is called itemno, It has  7 to 8 digits with no spaces. I need to change it so it has a space between the fourth and fifth digit. I tried a macro by starting to record making it relative, then hitting F2(to edit), then the home key to go to the start of the field, then I hit the right arrow 4 times, then I add a space, then hit enter. It jumps to the next row. I thought this would work, but it repeats the number from the first cell over and over in every cell instead of adding a space to the data that was in that cell. I have tried everything I know.

RE: excel macro

A macro seems to be the hard way. If you want a macro, just have the macro insert this function, copy it down, copy the cells with the formula, then paste special as values, then delete the original column.

Here's the formula you want, assuming your data starts in A1:

=left(a1,4)&" "&mid(a1,5,3)

The first part pulls the first 4 characters reading left to right.

The second part puts the space in. There IS a space between the double-quote marks.

The third part starts at the 5th character in the number, and pulls the next three characters. This particular one will work with 7-digit numbers. To use it with 8-digit numbers, you'll need it to read mid(a1,5,4).

You could sort the file by that column first, which will put the 7-digit numbers at the top, so you can change the formula when you start hitting 8-digit numbers.


dreamboat@nni.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close