+ Reply to Thread
Results 1 to 10 of 10

VB attached to button to pull templates based on values in specific cells

  1. #1
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    VB attached to button to pull templates based on values in specific cells

    Attached is the workbook I am trying to improve and I have made a macro attached to the “Build Report” button that does an example of what I am wanting to accomplish. Basically what I want to happen is when the “Build Report” button is clicked I want it to check what the 1st “Install Type” is, then pull a template over from the matching worksheet to the “overnight report” worksheet, then move to the 2nd “Install Type” and pull that template over to the “overnight report” worksheet and so on. What I have currently set up is just an example of what I would like the end result to be, but unfortunately it is very crude and if any of the info gets changed in the “Install Type” column, it will not change the outcome of the button. Right now, I'm wanting to make sure that I am on the right track in thinking that I will need to use VBA to accomplish this. I have never used VBA before so this will definitely be a learning experience for me. If I am on the right track, then I will start researching this. Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: VB attached to button to pull templates based on values in specific cells

    I have a few questions for clarification:

    -Do you simply want to copy the sheets based on the names in the "Install Type" column to the "Overnight Report" sheet one underneath the other?
    -One of the install types is "Win 10" but the corresponding sheet name is "Win 10 (ORACLE)" which means that this sheet name is based on the "Install Type" column andthe "Installer" column. Does the dependency on two columns happen only for "Win 10"?
    -Can you please explain in more detail what you mean by:
    if any of the info gets changed in the “Install Type” column, it will not change the outcome of the button
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    Re: VB attached to button to pull templates based on values in specific cells

    Quote Originally Posted by Mumps1 View Post
    I have a few questions for clarification:

    -Do you simply want to copy the sheets based on the names in the "Install Type" column to the "Overnight Report" sheet one underneath the other?
    YES

    -One of the install types is "Win 10" but the corresponding sheet name is "Win 10 (ORACLE)" which means that this sheet name is based on the "Install Type" column andthe "Installer" column. Does the dependency on two columns happen only for "Win 10"?

    The (ORACLE) part will be removed eventually, it was just there primarily for assisting with the learning curve.


    -Can you please explain in more detail what you mean by:
    I was just pointing out that the "build report" button on the attached sample spreadsheet is linked to a recorded macro.

  4. #4
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    Re: VB attached to button to pull templates based on values in specific cells

    I've attached an updated copy of my workbook with a few new buttons to help better simulate what I am trying to accomplish.
    Attached Files Attached Files

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: VB attached to button to pull templates based on values in specific cells

    Start by populating the Overnight Summary sheet data from columns E to L then assign the macro below to the Build Report button:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    Re: VB attached to button to pull templates based on values in specific cells

    When using this I get a run-time error '429': ActiveX component can't create object.Attachment 657847

  7. #7
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    Re: VB attached to button to pull templates based on values in specific cells

    I've updated the code and change the CreateObject to GetObject, Now I am getting "Run-time error'13' : type mismatch.

    Sub CopyData()
    Application.ScreenUpdating = False
    Dim Rng As Range, RngList As Object, srcWS As Worksheet, desWS As Worksheet, item As Variant
    Set srcWS = ThisWorkbook.Sheets("Overnight Summary")
    Set desWS = ThisWorkbook.Sheets("Overnight Report")
    Set RngList = GetObject("Scripting.Dictionary")
    For Each Rng In srcWS.Range("H11", srcWS.Range("H" & srcWS.Rows.Count).End(xlUp))
    If Not RngList.Exists(Rng.Value) Then
    RngList.Add Rng.Value, Nothing
    End If
    Next
    For Each item In RngList
    Sheets(item).UsedRange.Offset(1).Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1)
    Next item
    Application.ScreenUpdating = True
    End Sub

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: VB attached to button to pull templates based on values in specific cells

    It works properly for me. Try the attached file. Click on the "Build Report" button.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-08-2019
    Location
    Shawnee, Oklahoma
    MS-Off Ver
    Office 365 ProPlus
    Posts
    51

    Re: VB attached to button to pull templates based on values in specific cells

    It must have been something with how I copied it over. I pulled the data over from the workbook you sent and it works there as well. This is a great start, Thank you very much.

    There are some tweaks that I need to try and make, but I will open a new post for that if I can't figure it out. Which is likely, but I still want to try and figure it out myself first.

    Thank you again.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: VB attached to button to pull templates based on values in specific cells

    You are very welcome.

+ 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] Button-macro to read ranges of cells and return values of other cells based on results
    By TnD_Guy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-06-2019, 04:45 PM
  2. [SOLVED] Enable button if specific cells have values
    By bobbieatendido in forum Excel General
    Replies: 5
    Last Post: 07-13-2016, 06:10 AM
  3. Macro / formula to pull values from cells based on headers
    By Hypex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2016, 07:36 AM
  4. Button to generate new sheets based on templates
    By kdr2903 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2015, 12:14 PM
  5. update list with specific cell values in uncreate sheets (templates)
    By dmendes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2013, 03:48 AM
  6. Display a specific result based on Cell Values in a row (Ex Attached)
    By chadly72 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2013, 03:15 PM
  7. Replies: 3
    Last Post: 03-28-2011, 10:53 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