+ Reply to Thread
Results 1 to 9 of 9

Selecting and Copying Columns Based on Combobox Selection V2

  1. #1
    Registered User
    Join Date
    03-26-2021
    Location
    New York, USA
    MS-Off Ver
    365
    Posts
    20

    Selecting and Copying Columns Based on Combobox Selection V2

    Hello again Excelforum!

    A couple of months ago, I asked for help with an issue I was having with some ancient spreadsheets converted over to excel. The solution I received worked for the most part, but the issue of inconsistent formatting kept coming up, and I had no idea how the code actually worked. Last time my data was very inconsistent, so it was super difficult to select things properly without some blank space ruining everything.

    Now I've redone the entire data sheet and everything should be uniform. We have a location name and a block of info about their purchases surrounding them. I tried reusing the solution to my old problem, but I couldn't really grasp what the code did in the slightest. Would someone be able to help me out?

    Essentially I want to:
    1. Take a location name from the combobox (Pulling from the list directly below it)
    2. Pull all the relevant info from the shipping register into the correct columns on the packing list (Everything that has a colored background)
    3. Have the code be easy enough to tweak in case we get new locations or the formatting changes

    Hopefully this all makes sense. Thank you very much!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    03-26-2021
    Location
    New York, USA
    MS-Off Ver
    365
    Posts
    20

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Thank you very much protonLeah!
    If it isn't too much trouble, would you be able to walk me through how exactly the code for this works? I understand bits and pieces of it, but I want to have a good understanding of it, so I can implement it into my real project and fix any issues that might arise in the future.

    To start, I don't actually know how to put this into the workbook to begin with.

    EDIT: I figured out how to implement it into the workbook. It is also working like a charm with a little tweaking for my real project!

    I just had one more issue. I'm not sure if you saw or not, but there was also a yellow color coded cell for "Total Gross Weight" at the bottom of each block. That needs to go at the bottom of the Packing List as well. (Sheet 1 - E53) Is there a smooth way to include that cell as well?
    I am also still interested in learning more about how the macro does what it does, despite having a slightly better grasp on it.
    Last edited by J3Xtrom; 07-07-2021 at 01:00 PM. Reason: Figured out most of my issues

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    The line:
    Set RngBtm = .Range("A:A").Find("TOTALS", RngTop)
    locates the first occurrence of "TOTALS" below the "test location" then, the line
    RngBtm = RngBtm.Row - 1
    subtracted one from the found row to move up one row, so just delete the - 1 to keep the totals row.
    Last edited by protonLeah; 07-07-2021 at 03:12 PM.

  5. #5
    Registered User
    Join Date
    03-26-2021
    Location
    New York, USA
    MS-Off Ver
    365
    Posts
    20

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Quote Originally Posted by protonLeah View Post
    The line:
    Set RngBtm = .Range("A:A").Find("TOTALS", RngTop)
    locates the first occurrence of "TOTALS" below the "test location" then, the line [INDENT]RngBtm = RngBtm.Row - 1 [/INDENT]subtracted one from the found row to move up one row, so just delete the - 1 to keep the totals row.
    I don't need the entire line. I only want the one cell from a column that doesn't otherwise get pulled from the page. (Column G)
    While tinkering around with it, I did manage to make a new variable to put into that cell, but I messed something up.

    I can't remember how I wrote it exactly, but I ended up adding 6 in an attempt to get over to the G column, but the variable ended up being the "TOTALS" Row# + 6. So it always showed as 24 when selecting the first location for example. I'm probably missing something super obvious lol.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Try adding as the last line of code before "End Sub":
    'put total gross weight in cell E53
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-26-2021
    Location
    New York, USA
    MS-Off Ver
    365
    Posts
    20

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Works perfectly. Thank you so much!

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,964

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Some explanatory comments:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-26-2021
    Location
    New York, USA
    MS-Off Ver
    365
    Posts
    20

    Re: Selecting and Copying Columns Based on Combobox Selection V2

    Thank you again. I really appreciate you going out of your way to comment the code for me.

+ 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] match and update brands from comboboxes with columns based on selection combobox
    By abdo meghari in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-15-2021, 08:27 AM
  2. ComboBox values source being changed based on another combobox selection in a UserForm
    By stephenanderson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2016, 11:12 PM
  3. [SOLVED] Code required to Auto Populate 3rd Combobox based on 02nd Combobox Selection
    By bimmy80 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-14-2015, 03:56 AM
  4. [SOLVED] Change next ComboBox list based on previous ComboBox selection
    By SteveTheFish in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2015, 11:23 PM
  5. Populating Combobox based on Combobox selection from EXCEL worksheet
    By JChaney17 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-04-2014, 08:14 AM
  6. Selecting Multiple columns based on headers and copying to seaperate sheet
    By jonto81 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2013, 10:44 AM
  7. [SOLVED] fill combobox selection based on a selection from the first combobox
    By Monza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-14-2013, 07:34 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