Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-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!

*Eng-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 Format Problem

Excel Macro Format Problem

Excel Macro Format Problem

I have the following in a macro:

    For i = 1 To endRow
        PN = ActiveCell.Value
        EC1 = ActiveCell.Offset(0, 1).Value
        If EC1 = "" Then GoTo Next_PN
        For j = 3 To Worksheets.Count
            ACV = ActiveCell.Value
            If ACV = PN Then
               ActiveCell.Offset(0, 16).Value = EC1

My If check never finds a match because PN=1234 and ACV="1234".  Originally PN was formatted general and ACV as text.  I reformatted ACV as general but I still don't get a match. How do I fix this?  

RE: Excel Macro Format Problem


Instead of = try Like

Hope this helps.

maybe only a drafter
but the best user at this company!

RE: Excel Macro Format Problem

That worked perfectly.  Thanks.

RE: Excel Macro Format Problem


it appears that the vba code sees PN as a number and ACV as text, regardless of formatted type. while the "like" comparason may suffice the needs, the cell function =value(B4) converts text to a numeric value. hence, the comparason can be made with like data (i.e. comparing numbers).

good luck!

RE: Excel Macro Format Problem

That would be best but each of 7 suppliers has 20+ part numbers each on their own worksheet.  I have the files shared for multiple users and I don't fancy missing the season premier of Smallville tonight to do it when no one is around.

Apparently the guy who started these files formatted everything in the top x lines as text.  Had he left them as general I think everything would have worked.

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 Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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


Close Box

Join Eng-Tips® Today!

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

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close