+ Reply to Thread
Results 1 to 21 of 21

VBA: Arrange Dealer group information in different sheet.

  1. #1
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    VBA: Arrange Dealer group information in different sheet.

    Looking for a simple VBA.
    DATA is in the Input sheet and gets the output as in OutputX, OutputY, and OutputZ.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,148

    Re: VBA: Arrange Dealer group information in different sheet.

    Please Login or Register  to view this content.
    I cleaned up the "Input"t sheet (double commas ",,"", erroneous subset numbers!)
    Attached Files Attached Files
    Last edited by JohnTopley; 08-28-2022 at 11:14 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Thank you. But if I change the dealer information (in column B)with a long text introduction with the address there then I find an issue in the line:
    xstr = xstr & Mid(ar(i, 2), n1, n2 - n1) 'ouput for "outputx".

    For example the problem occurs when I put the below Delear information in column B
    Dealer information:
    (1)State State State State State State State State State State, State State
    State State, State State State State State State, State State
    State State State State, State State State State, State, State.
    (2)State State State State State State State State State, State State
    State State, State State State State State State, State State
    State State State Staten, State State State State, State, State; State State
    State State State, State State State State State State,
    State, State. State State: State.
    Last edited by first_jaguar; 09-01-2022 at 04:19 PM.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    Making use of your actual supplied file...This produces the exact result you expected...
    Please Login or Register  to view this content.
    Am away again for a while...Will check in again when available...
    Attached Files Attached Files
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Thank you but this line gets highlighted in yellow: OutX(x, 2) = IIf(OutX(x, 2) = "", Mid(Info, Pos1, Pos2), OutX(x, 2) & Mid(Info, Pos1, Pos2))

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    The code runs perfectly for me...Have you changed anything in the file...

  7. #7
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Yes Sir...I added the multi-paragraph "Dealer information:" with their numbers and I got this problem
    Also if the dealer name is say John W Smith in output cells it becomes JohnwSmith. "o va R(2)" becomes "ovaR(2)".
    Last edited by first_jaguar; 09-02-2022 at 06:06 AM.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    So...upload the file with the changed data so we can see...
    You need to remember the code is written for your exact request...The code provided gave the exact result you provided for that supplied file...
    If you go and change the data or it's layout, then it is obvious that the code will not work...

  9. #9
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Please find the attachment with the Demo text. Hope you will understand.
    There are many rows in the original data.
    Attached Files Attached Files

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    Code errors because you do not have closing brackets for (2)

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,148

    Re: VBA: Arrange Dealer group information in different sheet.

    No sample output provided!

  12. #12
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA: Arrange Dealer group information in different sheet.

    Also if the dealer name is say John W Smith in output cells it becomes JohnwSmith. "o va R(2)" becomes "ovaR(2)".
    I got my solution thanks, everyone.
    Last edited by trueb; 09-02-2022 at 07:09 AM.

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    Also if the dealer name is say John W Smith in output cells it becomes JohnwSmith. "o va R(2)" becomes "ovaR(2)".
    Attached solves...Tx for rep +
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Quote Originally Posted by sintek View Post
    Attached solves...Tx for rep +
    Hi sintek, in some rows I have dealer groups and Product/contact up to (50+). In such a case, the VBA is not running and showing an error.

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,148

    Re: VBA: Arrange Dealer group information in different sheet.

    Post a sample file with the 50+ dealer groups / product/contact
    Last edited by JohnTopley; 09-12-2022 at 01:10 PM.

  16. #16
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Quote Originally Posted by JohnTopley View Post
    Post a sample file with the 50+ dealer groups / product/contact
    Sir, The first attached file has 6 dealers in the group in row cell A2. If I copy the same multiple times and make 50 different names by simple modification the VBA is not working. The VBA works for a max of up to 7 members in a dealer group. And there can be 50+ members in a dealer group.

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,148

    Re: VBA: Arrange Dealer group information in different sheet.

    Try this change to code:


    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    Quote Originally Posted by JohnTopley View Post
    Try this change to code:


    Please Login or Register  to view this content.
    It worked. Thank you....but I faced another problem.
    If o va R(2)(9)(10)(11)(12)(13)(14)(15)(16)(17)(18)(19)(20) is like this then
    Run time error 5
    Invalid procedure call or argument
    clicking debug highlights this line
    Please Login or Register  to view this content.
    Now where can I make a change ?

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,167

    Re: VBA: Arrange Dealer group information in different sheet.

    See if this solves...
    Attached Files Attached Files
    Last edited by sintek; 09-14-2022 at 02:53 AM.

  20. #20
    Registered User
    Join Date
    06-23-2017
    Location
    London, England
    MS-Off Ver
    2007, 2010
    Posts
    24

    Re: VBA: Arrange Dealer group information in different sheet.

    I have found an issue:
    (#) to (#) should work copying whatever is in between them.
    I mean if there are ";" ":" etc characters between (#) to (#) in any cell in the Input sheet then the VBA asks to debug.
    Here, # means numbers inside brackets. Also in place of numbers if brackets are with (#) or (;|-), etc then also the VBA can not run.

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VBA: Arrange Dealer group information in different sheet.

    Quote Originally Posted by first_jaguar View Post
    DATA is in the Input sheet and gets the output as in OutputX, OutputY, and OutputZ.
    try
    Please Login or Register  to view this content.
    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. Fetch dealer name basis dealer code and sort
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2022, 06:44 PM
  2. Macro to fetch the nearby date from Sheet 2 basis Dealer id and date mentioned in Sheet 1
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2020, 01:16 AM
  3. automatically update dealer wise sheet with reference of Summery Sheet.
    By sharaftali in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-24-2018, 04:58 AM
  4. Replies: 5
    Last Post: 06-28-2017, 11:47 PM
  5. Replies: 7
    Last Post: 06-11-2015, 07:21 PM
  6. Arrange or group folders based on the assigned icons to Folders using vba
    By sanits591 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2011, 02:04 AM
  7. Arrange information alphabeticly in excel
    By Ky in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-07-2006, 08:20 AM

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