• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Looking to copy data from one datasheet to another based on condition

Anne Carlton

New Member
Hello, I am very new to the site and have found so many useful things so far, but i havent been able to solve one problem. I would like to move information from a row into another sheet when a specific condition is selected.

In my example specifically, i want to take the course name, found in column B of the Env Training Courses tab, and move it to column A of the Facility Training Plan tab, when Yes is selected in column four of the Env Training Courses tab. I would like the button to activate the macros on the Facility Training Plan tab (not sure if that makes a difference).

Any help would be fantastic!
 

Attachments

  • Training Plan.xlsm
    32.6 KB · Views: 4
Code:
Sub Cover_Click()
    Dim intPlanStartRow, intCourseStartRow
    Dim intCourseCol, intLoop, intCourseLastRow
    Dim intAcc, intCourseRequirementCol
   
    intPlanStartRow = 3
    intCourseStartRow = 4
    intCourseCol = 2
    intCourseRequirementCol = 3
   
    With ThisWorkbook
        .Sheets("Facility Training Plan 2015").Range("A" & intPlanStartRow & ":A10000").ClearContents
        With .Sheets("Environmental Training Courses")
            intCourseLastRow = .Cells(.Rows.Count, intCourseRequirementCol).End(xlUp).Row
            For intLoop = intCourseStartRow To intCourseLastRow
                If .Cells(intLoop, intCourseRequirementCol) = "Yes" Then
                    intAcc = intAcc + 1
                    .Parent.Sheets("Facility Training Plan 2015").Cells(intAcc + intPlanStartRow - 1, 1).Value = .Cells(intLoop, intCourseCol).Value
                End If
            Next intLoop
        End With
    End With
End Sub
 
Back
Top