+ Reply to Thread
Results 1 to 8 of 8

Find Post code within row and move to specific cell within same row.

  1. #1
    Registered User
    Join Date
    06-24-2016
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    7

    Find Post code within row and move to specific cell within same row.

    Hi,

    Some of the data that I'm importing does not always come across in the correct format. Meaning that my data doesn't land int he right cells.

    In this case I am trying to find references of post code SE9 across rows.

    It will only ever appear once in a row.

    Due to the inconsistent data entry on the imported list, the post code will appear in either column E, H and I.

    I would like to have a macro that would search those columns for SE9, and if found, cut and past it to the same row in column F.

    Is this possible? While doing searches I've been finding a lot of things on the Right, Left, Mid functions but don't think this applies.

    In reality, I would need a macro that would check for multiple values across those columns (SE9, SE18, SE1, SW9, W1) and move them all to the same cell within their row.

    Thanks in advance for anyone who can point me in the right direction.

    Frank

    excel test.jpg

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Find Post code within row and move to specific cell within same row.

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    To add a file to a post

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find Post code within row and move to specific cell within same row.

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Registered User
    Join Date
    06-24-2016
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    7

    Re: Find Post code within row and move to specific cell within same row.

    Thanks for this Walruseggman,

    This code works to find all of the values but once I run the macro they seem to disappear, not populate in a column. I still need columns E,H and I searched but need the info moved to column J in the same corresponding row.

    I have no experience with VBA so I'm not exactly sure how to set the found items to be placed in col J from the code above.

    Any help would be appreciated.

    Thanks,

    Frank

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find Post code within row and move to specific cell within same row.

    Posting an example workbook that replicates the problem you are seeing would help a great deal.

  6. #6
    Registered User
    Join Date
    06-24-2016
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    7

    Re: Find Post code within row and move to specific cell within same row.

    Hi Walruseggman,

    While I was creating my example workbook I actually discovered what the code was doing. I've now set it up and tweaked it just a bit and its working great.

    I do have a question though. Lets say I run the macro on columns B,C,D,E to find the post codes and set the destination column to 6 (col F) the numbers will populate.

    However, if I try to set the destination column as one of the first columns I searched in (2,3,4,5) the info won't populate it will just disappear. I started this example on Col 2 so I could try to set the destination to Col 1 but still not results. Just wondering if this code only works from left to right.

    Thanks for you help on this. This is going to save me hours and give me clean data!!

    If you think you'd like to see an example work book for this then I can attach.

    Thanks,

    Frank

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find Post code within row and move to specific cell within same row.

    It shouldn't matter where the destination column is. Can you post an example workbook where it doesn't work as expected, noting which column you're trying to output to?

  8. #8
    Registered User
    Join Date
    06-24-2016
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    7

    Re: Find Post code within row and move to specific cell within same row.

    Hi,

    Apologies for the late reply on this.

    I have made a sample workbook.

    Little bit of history (because I dont know if it will matter or not)

    The original code you gave me works fine. If I put it into an empty workbook it works flawlessly every time. It falls apart if I try and implement it with other data on the page.

    The original verson of the attached workbook actually has 12 active page tabs and as you can see from the macros section, has 5 or 6 other macros that i use.

    I have taken your original code posted below and re-worked it to include the ranges and destination cells I currently require. To be sure, these are.
    1. Search Col H,I,J,K,L for the following values
    2. a = Array("SE3", "SE7", "SE8", "SE9", "SE10", "SE13", "SE14", "SE18")
    3. If found, move those values to Col 13 (M) - In the same row that they were found in

    One thing to note is that there are already some values in Col 13. I would like those values that are already there to remain unchanged.


    After changing the code to suit my needs and running it on the "Output" page of the attached file I receive a whole host of errors (seemingly randomly). These include. Runtime 5 Error (Most Common), Excel Crashing and a Complie Error: "Next Without For".

    The name of the macro currently being used to perform the function is move_postcode_2

    Any help is much apperciated and thanks again for getting me this far.

    Frank
    Attached Files Attached Files

+ 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] Find a column by name, move it to specific location
    By axtryo in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-25-2016, 10:50 PM
  2. Macro to move code to cell, print, then move down the list to the next code
    By MilesDeep in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2014, 04:59 PM
  3. Replies: 5
    Last Post: 12-18-2013, 10:33 PM
  4. [SOLVED] Find and move cell to specific range
    By pradeepdeepu_001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2012, 11:38 AM
  5. Replies: 5
    Last Post: 05-01-2012, 04:02 PM
  6. Find specific and Move
    By cnsxad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2009, 05:15 PM
  7. UDF code to find specific text in cell comments, then average cell values
    By bruch04 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2005, 06:10 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