+ Reply to Thread
Results 1 to 5 of 5

Compile a list from 1 worksheet and copy or populate a new worksheet within the workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    11-21-2014
    Location
    USA
    MS-Off Ver
    2007
    Posts
    2

    Compile a list from 1 worksheet and copy or populate a new worksheet within the workbook

    I am attaching the file in its current state........ All of the info needed is on the comments page or 2 page in the workbook.
    Any help will be greatly appreciated.

    The request, for others that may search for the same answer is.......

    Need a list to populate on another worksheet using data (conditions) from another.

    Example.
    Need all Locations, that need repair/replacing or need to be watched, to populate a list on another worksheet. Which will allow
    the technician to type in comments on the repair needed. Then print it and add to the service contract.

    I also need it to adjust the list to fit as many locations as necessary.


    Thanks a mil!
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compile a list from 1 worksheet and copy or populate a new worksheet within the workbo

    Hi cblgod1

    Welcome to the Forum!!!

    In your Sample File, what is the Room (perhaps Water Heater?)? What is the Location (perhaps Safety Sticker?)?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    11-21-2014
    Location
    USA
    MS-Off Ver
    2007
    Posts
    2

    Re: Compile a list from 1 worksheet and copy or populate a new worksheet within the workbo

    Room= kitchen, bathroom, etc.
    Location= faucet, valve, etc.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compile a list from 1 worksheet and copy or populate a new worksheet within the workbo

    Hi cblgod1

    I assumed such...get back to you.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Compile a list from 1 worksheet and copy or populate a new worksheet within the workbo

    Hi cblgod1

    This Code is in the attached. All Code is in the Code Module for Sheet Checklist. Let me know of issues.
    Option Explicit
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim myLocation As String
      Dim wsSrc As Worksheet, wsTgt As Worksheet
      Dim lrTgt As Long
      Dim Rng As Range
    
      Set wsSrc = ActiveSheet
      Set wsTgt = Sheets("Template")  'Change this to your actual outoput Sheet Name
    
      If Target.Cells.Count > 1 Then Exit Sub
      Set Rng = Union([C7:C16], [C18:C22], [C24:C31], [F7:F22], [F24:F29], _
                      [I7:I11], [I13:I22], [I24:I25], [I27:I28], [I30:I32])
      If Not Intersect(Target, Rng) Is Nothing Then
        Select Case Target.Value
        Case "Watch", "Replace/Repair"
          'From http://www.tushar-mehta.com/publish_train/xl_vba_cases/1001%20range.find%20and%20findall.shtml#_Using_the_SearchFormat
    
          'Find Room Caption
          With Application.FindFormat
            .Clear
            With .Interior
              .ThemeColor = xlThemeColorDark1
              .TintAndShade = -0.349986266670736
            End With
          End With
    
          'Room Name
          myLocation = Cells.Find(What:="", after:=ActiveCell, LookIn:=xlFormulas, _
                                  LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, _
                                  MatchCase:=False, SearchFormat:=True).Offset(0, -2).Address
          With wsTgt
            lrTgt = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                                SearchDirection:=xlPrevious).Row + 1
            .Cells(lrTgt, "A").Value = wsSrc.Range(myLocation).Value  'Room
            .Cells(lrTgt, "B").Value = wsSrc.Range(Target.Address).Offset(0, -2).Value  'Location
            .Columns("A:I").Columns.AutoFit
          End With
        Case Else
          'Do Nothing
        End Select
      End If
    End Sub
    
    
    Private Sub CommandButton1_Click()
      Dim wsSrc As Worksheet, wsTgt As Worksheet
      Dim Rng As Range
      Dim LR As Long
    
      Set wsSrc = Sheets("Checklist")
      Set wsTgt = Sheets("Template")  'Change this to your actual outoput Sheet Name
    
      With wsSrc
        Application.EnableEvents = False
        Set Rng = Union(.[C7:C16], .[C18:C22], .[C24:C31], .[F7:F22], .[F24:F29], _
                        .[I7:I11], .[I13:I22], .[I24:I25], .[I27:I28], .[I30:I32])
        Rng.ClearContents
        Application.EnableEvents = True
      End With
    
      With wsTgt
        LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                         SearchDirection:=xlPrevious).Row
        If LR = 2 Then LR = 3
        .Range("A3:I" & LR).ClearContents
      End With
    End Sub
    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. Replies: 0
    Last Post: 02-04-2013, 02:28 PM
  2. Replies: 3
    Last Post: 11-29-2012, 08:01 PM
  3. Copy a worksheet as a new workbook with sheet and book name from a list
    By simondon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2011, 10:52 AM
  4. Populate Workbook with a Worksheet for each ComboBox List Item
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2010, 05:15 AM
  5. Copy data from worksheet row and populate cells in worksheet 2
    By nutterino in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2009, 04:02 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