Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub locationFillDown()
- 'Initialization
- Dim test, prod As Worksheet
- Set prod = Sheets("SBL3N Production")
- Set test = Sheets("SBL3N Test Environment")
- Application.ScreenUpdating = False
- 'Msgbox
- MsgBox ("The process of populating locations takes a few moments. Any line items with no location will be blank.")
- 'Set prod Locations
- With prod
- Dim prodLastRow As Integer
- prodLastRow = .Range("M" & Rows.Count).End(xlUp).Row 'Used Column M bc it will always be populated
- End With
- prod.Activate
- Range("V2").Value = "=IF(IF(LEN(P2)=0,E2,LEFT(P2,4))=0,99999,IF(LEN(P2)=0,E2,LEFT(P2,4)))"
- Range("V2:V" & prodLastRow).FillDown
- For Each prodCell In Range("V2:V" & prodLastRow)
- If prodCell.Value = 99999 Then
- prodCell.ClearContents
- End If
- Next prodCell
- 'Set test Locations
- With test
- Dim testLastRow As Integer
- testLastRow = .Range("C" & Rows.Count).End(xlUp).Row 'Used col C bc it will always be populated
- End With
- test.Activate
- Range("Q2").Value = "=IF(AND(ISBLANK(J2),ISBLANK(K2)),99999,IF(LEN(J2)=0,K2,LEFT(J2,4)))"
- Range("Q2:Q" & testLastRow).FillDown
- For Each testCell In Range("Q2:Q" & testLastRow)
- If testCell.Value = 99999 Then
- testCell.ClearContents
- End If
- Next testCell
- Application.ScreenUpdating = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement