+ Reply to Thread
Results 1 to 6 of 6

for loop with an instring

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Boston
    MS-Off Ver
    Excel 2010
    Posts
    26

    Thumbs up for loop with an instring

    Hello,

    I have to loop through column and if column A starts with OJT then change Item type to OJT, else do nothing and continue.

    Any help on this would be so appreciated.

    A B
    Item ID Item Type
    GI-WRS-CBT Course
    IATA123 Course
    OJT-014-33 SOP
    OJT-014-26 SOP
    OJT-014-39 SOP
    OJT-014-35 SOP
    OJT-014-35 SOP
    OJT-014-35 SOP
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: for loop with an instring

    Why bother with a macro, particularly one that uses a loop which is generally inefficient and time consuming with large data sets when there is a perfectly good standard Excel Function. e.g. in C2 copied down

    =IF(LEFT(A2,3)="OJT","OJT",B2)

    Then copy the whole of column C and paste it back to B1 as Values. If you really do want a macro then I'd simply code this process rather than use a loop.
    Last edited by Richard Buttrey; 08-15-2013 at 04:52 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: for loop with an instring

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: for loop with an instring

    Hi bruinsrme

    No looping required
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    04-15-2013
    Location
    Boston
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: for loop with an instring

    John I was able to run the code on my sample data. When I adjusted the code for column v and w I Fran into some issues.
    It's been a long day, I will try some things tomorrow.

    Thank you everyone

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: for loop with an instring

    Hi bruinsrme

    Long day for me too...let me know your issues...perhaps we can address them.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  2. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  3. Search & Replace InString
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-03-2010, 05:25 PM
  4. Include/Exclude Specific Instring Characters From A Querry Search
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-05-2010, 03:43 PM
  5. [SOLVED] Help with instring code
    By Elaine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-20-2005, 11:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1