+ Reply to Thread
Results 1 to 17 of 17

Need help with VBA for multiple functions

  1. #1
    Registered User
    Join Date
    04-06-2016
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    365
    Posts
    32

    Question Need help with VBA for multiple functions

    I am trying to learn to use VBA, but am struggling with finding the correct syntax (?) for an office project.

    We receive data that comes all in one column. There are generally 3 rows of actual information and then a blank line. This pattern repeats. Some datasets may only have a 25 or so "sets". Others can have over 1,000 sets.

    Challenge #1: Determine the last populated row (dataset contains blank rows). I can use a MATCH("zzz",A:A) formula to find the last row.


    Challenge #2: Transpose each "group", on a new worksheet.


    A very nice person on here helped me with a DROP(WRAPROWS) formula which uses the range found in Challenge #1. Ex: A1:A51. That same formula also "drops" the blank row/cell once the data is transposed.


    Challenge #3: Format the transposed data so that it becomes easier to read.


    Summary:

    Transpose all data from column A (with the last row always being a variable) on one sheet over to a 2nd sheet, add column headers and possibly convert the table to a range (or add borders) just to make the information easier to read.

    I feel like there is no single formula (or nested formulas) that will do all of that and that we probably need to use VBA to accomplish all of these things, but I am not experienced enough to write all of this.

    If anyone has time to help, it would be much appreciated.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by Diane Hogue; 11-17-2024 at 12:42 PM. Reason: Forgot to Attach Spreadsheet

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Need help with VBA for multiple functions

    Please update your profile. If you have DROP(WRAPROWS()), you are not using Excel 2016.


    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    272

    Re: Need help with VBA for multiple functions

    If you have Excel 2016, this formula may not work.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please try this VBA macro.

    Please Login or Register  to view this content.
    Last edited by RhiSJ; 11-16-2024 at 10:40 PM.

  4. #4
    Registered User
    Join Date
    04-06-2016
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    365
    Posts
    32

    Re: Need help with VBA for multiple functions

    Thank you! That is "almost" the desired result.

    Sample:
    {blank row}
    Item #1
    Time1
    Text1
    {blank row}
    Item #2
    Time2
    Text2
    {blank row}
    Item #3
    Time3
    Text3
    {blank row}
    Item #4
    Time4
    text4
    {blank row}

    What I'd like to end up with is each group transposed, starting on a new sheet:

    Item #1 Time1 Text1
    Item #2 Time2 Text2
    Item #3 Time3 Text3
    Item #4 Time4 Text4


    I hope I make sense!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Need help with VBA for multiple functions

    This:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Need help with VBA for multiple functions

    Updated to reflect the sample file data:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Update - Better:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by TMS; 11-17-2024 at 06:31 PM.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,523

    Re: Need help with VBA for multiple functions

    If you do want to use VBA here's a solution that works for your example file having 5 rows of data instead of the 3 you talk about in your 1st post.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,301

    Re: Need help with VBA for multiple functions

    ?
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 11-17-2024 at 07:43 PM.

  9. #9
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    272

    Re: Need help with VBA for multiple functions

    Try this code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by RhiSJ; 11-17-2024 at 09:23 PM.

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Need help with VBA for multiple functions

    As we love options...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 11-18-2024 at 03:54 AM.
    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 [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  11. #11
    Registered User
    Join Date
    04-06-2016
    Location
    Oklahoma City, Oklahoma
    MS-Off Ver
    365
    Posts
    32

    Re: Need help with VBA for multiple functions

    Thank you for spending so much time working on this. Unfortunately, I'm getting an error and the macro will not run.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,993

    Re: Need help with VBA for multiple functions

    Which macro? You've got five (if I’ve counted correctly).

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,523

    Re: Need help with VBA for multiple functions

    And more important, which error message are you getting?
    Post an example file which reflects the true situation of your data because the file you present in your 1st post doesn't represent your explanation in Post#4.

  14. #14
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    272

    Re: Need help with VBA for multiple functions

    I am sorry, I did not found you attached file,
    I modified the code, easy to read and reuse.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Need help with VBA for multiple functions

    I assume based on the rep points added...This is solved?

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,523

    Re: Need help with VBA for multiple functions

    Well Sintek, at least you got rep points. LOL

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Need help with VBA for multiple functions

    @bakerman2...Yeah...Don't quite understand that...

    Did you not...Yours too solves...

+ 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. Replies: 6
    Last Post: 03-17-2015, 01:35 AM
  2. Combining multiple functions>lookup/sum functions
    By mush106 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-22-2013, 07:47 AM
  3. [SOLVED] Help with multiple IF functions and possible lookup functions.
    By englishfellow in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-29-2013, 01:49 PM
  4. Replies: 4
    Last Post: 03-08-2013, 09:49 AM
  5. Replies: 4
    Last Post: 01-08-2013, 09:04 AM
  6. Multiple IF Functions or VLOOKUP functions
    By yinka00000 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-15-2012, 11:29 PM
  7. [SOLVED] multiple "if" functions depending on previous functions
    By andyr85 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-20-2012, 10:05 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