STEVEMILLS04
Board Regular
- Joined
- Oct 8, 2009
- Messages
- 113
Good day to all. I have the code below in my spreadsheet that works great as is, however, I need to make some adjustments and not sure how to do so.
First, I would like to make this a button rather than a Worksheet_Change event. How do I transition it to a Macro?
Second, when the code first runs, it should clear all information on rows 3 and on but only in particular tabs. I can manage and type the tab names, just need the basic template on how to program this.
Third, I would like the values of J AND D to drive when a row is copied. I currently just have J2:J. How do I change to code to include the values of D?
Finally, I would love if I could include multiple combinations. By this, I mean if J is Promotable and D is Community Mgr, copy row to the tab named Promotable CM. If J is Well Placed and D is Community Mgr, copy to tab named Well Placed CM. If J is Well Placed and D is Asst Community Mgr, copy to tab named Well Placed ACM. I think you get the idea. I can pre-create these tabs and do all the typing for the code, just need the template as I am not sure how to go about this.
Thank you SOOO MUCH for any help you can provide.
First, I would like to make this a button rather than a Worksheet_Change event. How do I transition it to a Macro?
Second, when the code first runs, it should clear all information on rows 3 and on but only in particular tabs. I can manage and type the tab names, just need the basic template on how to program this.
Third, I would like the values of J AND D to drive when a row is copied. I currently just have J2:J. How do I change to code to include the values of D?
Finally, I would love if I could include multiple combinations. By this, I mean if J is Promotable and D is Community Mgr, copy row to the tab named Promotable CM. If J is Well Placed and D is Community Mgr, copy to tab named Well Placed CM. If J is Well Placed and D is Asst Community Mgr, copy to tab named Well Placed ACM. I think you get the idea. I can pre-create these tabs and do all the typing for the code, just need the template as I am not sure how to go about this.
Thank you SOOO MUCH for any help you can provide.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
If Flag = True Then Exit Sub
If Not Intersect(Target, Range("J2:J" & LR)) Is Nothing Then
If Target.Value = "Promotable" Then
LR = Sheets("Test Promotable").Range("A" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy
Sheets("Test Promotable").Range("A" & LR).PasteSpecial
Flag = True
End If
End If
Application.CutCopyMode = False
Flag = False
End Sub