+ Reply to Thread
Results 1 to 50 of 50

Move cells based on cell length *shift cells right) - code required

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Move cells based on cell length *shift cells right) - code required

    Hi

    I have a database which when I export to excel it doesnt always come out in the same format.

    e.g.
    AT Business 1 1
    AU Business 2 2
    AV Business 3 3
    AW Business 4 4
    AX Business 5 5
    AY Business 6 6
    AZ Business 7 7
    BABusiness 8 8
    BBBusiness 9 9

    What I would like is a macro that looks at the cell lenth in column A.
    If it is 2 or less then do nothing.
    But, if it is more than two characters then I need it to put the first two characters in column one and then the remaining contents in column B (apart from the space) and shifting everything else along.

    It would then look like this:
    AT Business 1 1
    AU Business 2 2
    AV Business 3 3
    AW Business 4 4
    AX Business 5 5
    AY Business 6 6
    AZ Business 7 7
    BA Business 8 8
    BB Business 9 9

    Can anyone help with the code please?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Try the attached
    I have updated the code.
    Attached Files Attached Files
    Last edited by AB33; 11-14-2014 at 08:49 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    Thanks for this code - its very close to what I require, wondered if you could help make a couple of tweaks?

    Rather than it copy to a new "required" sheet can it make the amendments to the active sheet where the data is held?

    The other modifaction is the business name - it currently crops the name slightly. In the attached example I have amended the business names to Business ABC - this is what I would need displayed in column B.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Okay to the first request, but need clarification on the second.
    You have
    BA Business 8
    BB Business 9

    So, how do you get to ABC?

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    I re-uploaded a new example as my first example might have been misleading.

    If the cell is, for example, AABusinessXYZ then I would need in column A, "AA" and in column B "Business XYZ"

    but when it puts "Business XYZ" in it will need to shift cells right one

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I have checked both attachments, there is no update, i.e. the data are the same. It is difficult to read data on text format, so please attach an excel book which mimics your actual data.

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Sorry, try now. Unsure what happened there
    Attached Files Attached Files
    Last edited by pauldaddyadams; 11-14-2014 at 10:23 AM.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Try the attached.
    Attached Files Attached Files
    Last edited by AB33; 11-14-2014 at 11:28 AM.

  9. #9
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    Your spreadsheet works perfectly - it does excatly what I need it to do.

    When I paste this into my actual model though it doesnt work and I dont know why.

    You will see that this report has data in rows 12-188. When it has been exported it has exported rows 12:37 correctly but not the rest.

    This is why I need the macro to correct it - but on this file the macro isnt working - do I need to amend any of the code as its a new model?
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    It is easy to adjust the code, but do you still want words like "Page", Sub-total and Code to be included on the report as their length are >2?

  11. #11
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi

    The plan is to use your code after the one on this thread

    HTML Code: 
    So those that you mentioned should already be gone, I hope

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I do not know, but I have included two codes. The top code (without and output on sheet with out) excludes those lines, while the bottom (With) includes all.
    Try
    Attached Files Attached Files

  13. #13
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    Got back to this...

    I have tested the code and it deletes a column I need to keep.

    Before the code is run the cells I have highlighted in yellow are present but after the code is run they are deleted. Ideally I would need to keep them and shift cells right

    Can anyone help with the code for this please?
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Quote Originally Posted by pauldaddyadams View Post
    Hi,

    Got back to this...



    Can anyone help with the code for this please?
    Who is anyone?? I was tempting to ignore the thread but since I started it, I may well finish it.
    I gave you two codes. One deletes some of the lines and second one keeps all lines. It seems you have run the first code.
    Attached Files Attached Files

  15. #15
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    AB33 - I have sent a PM.

    I have attached an updated workbook now I have my other macro working. When I run the test macro to format the report and run both yours I still lose a column - am I doing something wrong?
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Okay! I see what is going on. Will correct it un momento

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I have been working on the original data where there were only 3 columns. I have now amended code, but I am assuming you have cleared data,that is, the code looks at the cell length in column A. Since words like "Year", "Subtotal", are also over 2 length, they will be split in to 2 columns.

    I can adjust the code as I did in the previous one to excluded splitting columns with sub total page and so on, but first try it the attached.
    Attached Files Attached Files

  18. #18
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi - that code works. If you could include the code which will exclude "sub total" etc then I think you have cracked it for me!

    Could you also include this please (Im unsure of where this would need to be included)

    Please Login or Register  to view this content.

  19. #19
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I have assumed the data first row is row 10. Try the attached.
    Attached Files Attached Files

  20. #20
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    Just tested it - things only come to light when I see it working. What I need is that if it finds "Sub Total" or "Grand Total" it would still shift cells right. On your attached B38 I would need to be blank and then the value to shift right - so the 0.17 appears in C38. Hope that makes sense?

  21. #21
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Try the amended.
    Attached Files Attached Files

  22. #22
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi AB33 - this done it!!!! Thank you so much for all your hard work!!

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Move cells based on cell length *shift cells right) - code required

    Unless you have an unusual font ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  24. #24
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi

    I thought this was working fully but I have encountered a problem…

    When the data exports from PDF correctly as in rows 12-31 on the attached the subtotal line is fine. However when its run through the macro it shifts it along right by one so its all out of sync.

    Is there any way in which a new rule can be included where it says if column A is subtotal and the cell to the right of it is blank then do not shift right, if not then do what the current code is doing.

    Can you help AB33 please?

    Ps - thanks Shg for the spelling correction!
    Attached Files Attached Files

  25. #25
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Is it the subtotal lines only, or do you want to include the grand total as well?
    To the right means column B. Is this right?
    Last edited by AB33; 11-19-2014 at 07:43 AM.

  26. #26
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Yes, thats right - column B

    Its Grand total also please, good spot!

  27. #27
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Try the attached.
    Attached Files Attached Files

  28. #28
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    This doesnt work - When I hit the macro it removes the subtotal. e.g. Row 31 on the sheet "Ori (2)" disappears.

    I have updated the file to show an "Ideal tab" - this is what I am trying to get to
    Attached Files Attached Files

  29. #29
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    No, all the sheets on the attached have already been split up so when you run the code, it will not do anything. Look at column B. Either try it on original data which has not split yet, or attach an orignal sample.

  30. #30
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    This is a file showing the original data and a sheet having run the macro - the sub total lines are being deleted on the rows only where the orignally pulled correctly
    Attached Files Attached Files

  31. #31
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Okay! Try it now
    Attached Files Attached Files

  32. #32
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Sorry for the delay in replying - I have been testing this to make sure its correct. Sadly it isnt and I do not know why...

    I have uploaded the model excatly how its exported with business descriptions as they appear on the orignal report, the only thing I have changed is the amounts.

    There are two reports APP024 and APP037 that the macro will be used on.

    APP024 - this is the one that isnt working as it is cutting some of the business's name. I have shown on the "APP024 Macro Run" sheet which ones have errors and what the desired results should be.

    APP037 - I have only tested this brifely and it appears to all be working.

    Would it be possible to take a look again please?
    Attached Files Attached Files

  33. #33
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I am not surprised it is not working. The exception to the report is growing by the day. I know you are converting data from PDF in to excel. There are unknown number of names and phrases you want to exclude from appearing on the report, but it is difficult to know which now names have been added to the new data.
    If you remember on the initial stage of the thread, I highlighted this issue, but you told me there is another code which removes these words. Infact, it was my idea to exclude these words.
    Last edited by AB33; 11-19-2014 at 11:33 AM.

  34. #34
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    I have run the other code in the attached which should get rid of all the other lines you mention - I do not understand what would be causing the text split as sometimes it works and sometimes it doesnt.

    In the attached i have highlighted in yellow the bits I need to fix but I need help understanding why the code is treating these cells differently.
    Attached Files Attached Files

  35. #35
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    There is a reason why the code may be behave strangely.
    For instance
    NOT USE
    INTERFACE X

    I have added another if statement to exclude
    "Inter Business Earnings Contributions"
    I need to include the entire sentence for the code to work correctly, but If I were just to use the word "Inter", this will give unwanted result.
    INTERFACE X
    is found on the word "Inter", so the code assumes they are equal even though they are not the same.
    Let's look at another example, row 66, "GRAND CENTRAL". We want to treat "Grand Total" as a separate issue. I have just want "Grand" Only as a match,but, both GRAND CENTRAL and "Grand Total" will match, but they are not the same, so to exclude and include each we have to include many ifs statements, but this is no by means will work in all circumstances.
    Another example is"NOT USE". The reason the code did not split it that it assumes "Business" partially match "USE".
    It will be a long and cumbersome code to cater for all words and phrases as your data are no consistent.
    I do not see any other approach as we using length of a word to evaluate a cell,but other people may approach differently.
    Last edited by AB33; 11-19-2014 at 12:50 PM.

  36. #36
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Just to show you what I meant was, look at the attached and see highlighted in yellow.
    The code excludes most rows which have word like "Business" as we do not want to split up a row which is a headline.The problem you will have is: It is over 2 length word, it has a word "Business on it", so the code treats it the same way as other lines which have the same word.
    I hope you got point.
    Attached Files Attached Files
    Last edited by AB33; 11-19-2014 at 01:04 PM.

  37. #37
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Ah - that does explain it. I can go in and add as many statements as possible.

    Why would "Business" partially match "USE?

    I dont understand why these would be blank (these appear in column A and columb B is blank)
    GA
    HC
    HD
    HE
    HO

    Is it only these: "Code", "Sub-Total", "Page", "Grand" its looking for? I know you mentioned "Inter" but I can not see this in your code?

  38. #38
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    I should be able to delete the business rule as this will be removed once I run my first code I think - I can not find the word business in the code, where is it?

    I can then test it

    I am refering to this code:

    Please Login or Register  to view this content.

  39. #39
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    [QUOTE=pauldaddyadams;3905549]Ah - that does explain it. I can go in and add as many statements as possible.

    Why would "Business" partially match "USE?
    "USE" is found inside the colour.
    Yes, this is partial match,you can use exact match, but how many words do you want to exclude and do you know these words?
    Since the data have been imported in excel, some of the lines have non-printing dirty characters, hence when the code loops, it might not find these lines.
    Last edited by AB33; 11-19-2014 at 01:12 PM.

  40. #40
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Module 2 on the last attachment.

  41. #41
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    I have now amended the code to pick-up exact words only, but you may hundreds of words and need to put them in the ifs statement. Please look at the attached (module 1) and see the coloured rows. row 42 is "Page 1 of 5", unless you want to include all exact match words which also means 100s of lines of code. I have used partial match to exclude all lines which have word "Page" in them, but this will also have unintended consequence matching words which have p,a,g,e in them
    I am not convinced the code will work, but it is your call and need to expand the if statement for 1000s of words.
    Attached Files Attached Files

  42. #42
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    AB33 - thanks so much for sticking with me on this and explaining like you have.

    I see your point. I really do not know the best way around this because as you suggest the only work around is 100 of lines of code.

    I was thinking about this last night and wondered (it does mean chaning the code quite alot).

    What if... say the code is only used to split the first two characters only into column A. Then, the code uses a lookup referencing a "Lookup Sheet" on that sheet it would have a list of 2 digit codes and the full name.

    What do you think?

  43. #43
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Hi pauldaddyadams,
    Okay, post your sample and will try it.
    Splitting column A is not the issue, you can use excel's text to columns function.
    The biggest headache you have is your data are constanly updated. If the data are fixed, you could run two separate codes. One to clean the data first by removing the unwanted lines, and use the second code to split up column A.
    I use a software to convert PDF in to excel. I have written codes to clean the data in excel, but I quite often need to update the codes. I know most words and layout of Bank statements and my codes work, but not always.
    The other issue you have which you have not noticed is sometimes the lines converted in to excel have merged lines or the row height is too small. Most imported data in to excel have unseen characters and cause lots of problem with matching.
    Last edited by AB33; 11-20-2014 at 05:19 AM.

  44. #44
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi,

    Sorry for the dealy - I couldnt access the forum yesterday

    Whats annoying is I have tried lots of PDF converters and they all seem to handle the data differently. Some reports I am using I am not even going to bother trying to reformat it as it appears on different rows, mergers data so the rules can not be written. Never knew about the unseen characters part - frustrating!

    I have attached the lookup I need.
    Attached Files Attached Files

  45. #45
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    Hi pauldaddyadams,
    Let's look at row 31 of lookup sheet
    AZ Tflc Interface

    This is found,AZ TFLC INTERFACE, on the main sheet on row 37.
    Let's also assume AZ (Split part) matches AZ of column (C) of sheet lookup. If you do Vlookup, it returns the values in column D.
    I need to understand what is your objective and why this is different to the previous approach?
    Yes, the code will get rid of all the unnecessary lines since there are no matches on sheet look up for these rows. It only returns for values which are in column C of sheet look up.
    How about if there are duplicates names?
    Just food for thoughts
    I do not know what software do you use to convert your PDF. As far as I know there is not perfect application. I have not used the professional adobe converter, but I have tried lots of third party software, but none of them work all the time. I know this is very frustrating. Lots of people tempted to write a VBA code, but none of them have succeeded as far as I know.

  46. #46
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi

    Doing it this way should correct two things:
    Blank descriptions in column B
    Incorrect trimming of names in column B

    In the example you said for AZ TFLC Interface the code works perfectly for that already so you wouldnt see a difference.

    If you take the example "BA" when the model is run the description is changed to "Not Use" rather than "Business Ba - Do Not Use" but using the lookup I am hoping it will pull the full name.

    Another example is "BB" - the macro returns "INTERFACE X" rather than the full name "Tflb Interface X"

    Another example is "GA" - the macro returns no description, with the lookup it should pull "Zz Eurostar (Uk) Ltd"

    What do you think?

    In terms of duplicates there shouldnt be any - the two letter part is unique to a customer.

    I am surprised that noone has managed to create a code but I guess it must be too difficult to create so many rules as all data is different. I tried Adobe Pro but that didnt work, it was one of the worst.

  47. #47
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    The problem is not a VBA code, but the document itself. If I was so easy to use a VBA, why do you think there are many third party software on the market?
    The issue you are having is still not resolved- what are going to do with all the rows where you do not want to split column A?
    Let's say, forget a VBA, use Excel's text to columns function. It can split column A, but indiscriminately. It would not differentiate between a row which has other words and a row with AZ TFLC Interface, hence the reason for looping through each row (VBA) and separate which row needs to split and a row which should remain unchanged. So, Unless I am missing something, we are back to square one.

  48. #48
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    Hi, this is what I thought I would need

    The code would run to either:
    • Find all the instances where column A is not 2 lengths in character and replace it with two just the first two characters. It would need to exclude the sub total , grand total etc words.
    • Or it could just replace column A with the first two characters (regardless if it pulled through or not correctly). Again it would need to exclude the sub total, grand total etc words.

    Then the code would then say for all rows which only have two characters in length in column A, use the lookup in column B to get the customer name.

    It would also have to apply the logic where if the data hasn’t pulled through correctly it will need to shift the cells to the right. Possibly, see if the data fills up to column H and if it doesn’t then select the range (for the row only) B:G and move it along one cell to the right. Or possibly if column B initially contains a number then shift to the right.

    Im throwing ideas out there – feel free to pick it apart

  49. #49
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move cells based on cell length *shift cells right) - code required

    This is my suggestion.
    Start a new thread.

    Do not refer it to this thread nor you should attach my code, so that others can see and start with fresh eyes and new ideas.
    Please attach a sample, but the sample has to represent your actual data layout, i.e. the length of rows and columns.
    We shall wait until Monday for reply. If no other alternative approach works, I will pick it up and will implement your latest ideas.

  50. #50
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Move cells based on cell length *shift cells right) - code required

    I have come up with the attached to give you an idea of a new way of thinking - just another suggestion. I will do as you suggest and see what others suggest using this as a basis
    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. Help Required - Concatenating cells contents into single cell, based on an ID
    By mharis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2013, 07:49 AM
  2. Replies: 0
    Last Post: 03-26-2013, 02:58 PM
  3. Replies: 3
    Last Post: 11-06-2012, 11:26 AM
  4. Recognizing a cell has a number or a zip code, if so shift cells to the right
    By ej463 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-17-2009, 01:06 PM
  5. Move/Shift cells left or right in a row
    By T.Taylor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-14-2005, 11:20 AM

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