+ Reply to Thread
Results 1 to 11 of 11

Searching for and moving data within a range of cells

  1. #1
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Searching for and moving data within a range of cells

    Hi everyone,

    This is only my second post and i could really do with your help:

    How do I get VB to go to a specific word within a column; then search within a predefined number of cells around itself to find the character '@'.

    EG: The word 'Distance' is first found in A2 (including multiple places randomly down column A). The email address '[email protected]' could be anywhere within the range A2:B6. Once the email address is found I need VB to replace the cell containing 'distance' with the cell containing the email address. The process repeats for every cell containing 'distance' with the same predefined range (2 columns wide, 5 rows deep)

    any help would be great. I would have tried to present some coding of my own but I have no Idea how it might look.

    Cheers.

    Tom

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Searching for and moving data within a range of cells

    a sample file would be helpful
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Searching for and moving data within a range of cells

    of course... see sample below

    also, just to add I would like the same thing to happen where 'weekends' appear and replace it with the mobile number showing next to Contact Number.

    I basically need the information to be displayed next to each other thus:

    Column A Column B Column C Column D Column E ColumnF
    NAME blank blank MOBILE NUMBER EMAIL ADDRESS REGISTERED/Trainee


    cheers
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Searching for and moving data within a range of cells

    It's not clear for me, no word 'Distance' in column A, attach a file with sheet before an after

  5. #5
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Searching for and moving data within a range of cells

    Sorry, it was a bit rushed. I'll try again.

    Sheet1 contains a sample of the unedited data, Sheet 2 shows my intended end result. I have tried recording Macros in an attempt to sort the data step by step (very clumsily I expect)and I've found some of the data does not go where I need it to be (ie nicely lined up in rows)and as a result some of it gets lost towards the final stages.

    I would really appreciate some help with getting it accurate.

    thanks

    Tom
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Searching for and moving data within a range of cells

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Searching for and moving data within a range of cells

    thanks for your reply. I've copied your code into a new module but nothing seems to happen. Any ideas as to what i should do?

    thanks

    tom

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Searching for and moving data within a range of cells

    see second sheet

  9. #9
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Searching for and moving data within a range of cells

    Hi,Patel45. Thanks a lot for that, I think you're nearly there! however with a larger amount of data it doesn't always get it quite right. Your code seems to assume that the data required will always be in the cell you have directed it to look in, sometimes it will be, but as you will see this is not always the case. The correct piece of information could be in the cell below it.

    For example the presence of an additional telephone, or a blank cell instead of a telephone number or an email address (which is actually in the cell below). I have attached a new spreadsheet to show how your code has responded to a larger amount of data.I don't understand code enough to tweak it myself.

    On the question of telephone numbers, ideally I would like to move only numbers starting with 07 and delete numbers starting with 01

    If you can resolve these issues I would be very greatful.

    thanks again.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Searching for and moving data within a range of cells

    I need a sample file with possible cases and desired output

  11. #11
    Registered User
    Join Date
    11-06-2012
    Location
    leicester
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Searching for and moving data within a range of cells

    Hi,

    See Sample1 attachment.

    Sheet1 shows the original data
    Sheet2 shows the result of the code you wrote. (some data is in the wrong place)
    Sheet3 is the intended end result.

    Some people have two phone numbers I only want to keep numbers starting 07, the person's email address and status (registered/trainee)

    If a person does not have a number or email address then cells should remain blank.


    Thanks again
    Attached Files Attached Files
    Last edited by tomscogg; 11-10-2012 at 05:07 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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