Public Sub RollupData_ExtractCodes(lngTotalRows As Long)
'----------------------------------------------------------------------
' Purpose: Extract the Brand and Department Codes from "data_File"
' column in the wsData. Brand code is placed in the Brand Col
' and Department in the Dept col
' Returns: -
' Usage: call RollupData_ExtractCodes()
' Developer: [MSTEVE]
'-----------------------------------------------------------------------
Dim rngData As Range
Dim rngAdd As Range
Dim lngRow As Long
Dim strFile As String
Dim arrBrandDept As Variant
Dim strBrand As String
Dim strDept As String
Dim lngAssignRows As Long
On Error GoTo Err_Handler
'--- Set the Data Range to Validate [From data_brand to data_file]
'--- Loop through the range making the changes
For Each rngData In wsData.Range("data_Brand").Offset(1, 0) _
.Resize(lngTotalRows, g_offData_MCTFile).Rows
'Increment the row number for Progress Status
lngRow = lngRow + 1
'Tell the user the row we are validating
Call DisplayProgress("Extracting Brand / Department: Row(" & lngRow & ")")
'Record the file name
strFile = rngData.Cells(1, g_offData_MCTFile)
'Record the Number of in the Assigned range
lngAssignRows = TotalRowsInRange(wsAssign.Range("assign_File"))
'--1-- Validate if this File has already been validated and placed in the
' assigned sheet. The user may have already assigned codes
arrBrandDept = GetUserExtractedCodes(strFile, lngAssignRows)
If Not IsEmpty(arrBrandDept) Then
With rngData
'Brand Code
.Cells(1, g_offData_Brand) = arrBrandDept(0)
'Dept Code
.Cells(1, g_offData_Dept) = arrBrandDept(1)
End With
Else
'--2-- Otherwise, try to extract the codes programitically
'Extract the Brand Code
strBrand = ExtractBrand(strFile)
rngData.Cells(1, g_offData_Brand) = strBrand
'Extract the Dept Code
strDept = ExtractDepartment(strFile)
rngData.Cells(1, g_offData_Dept) = strDept
'--3-- Validate if Either value is blank - if so, write the file to the
' manual user assigned list
If strBrand = g_strUnknownValue Or _
strDept = g_strUnknownValue Then
'-A- Find the Last Row in the wsAssign Range, increment by one
Set rngAdd = wsAssign.Range("assign_File").Offset(1 + lngAssignRows, _
-(g_offAssign_File - g_offAssign_Brand))
'-B- Copy the Template Formate Row and Paste
wsTemplate.Range("assign_TemplateRow").Copy rngAdd
'-C- Write the values to the range
With rngAdd
.Cells(1, g_offAssign_Brand) = rngData.Cells(1, g_offData_Brand)
.Cells(1, g_offAssign_Dept) = rngData.Cells(1, g_offData_Dept)
.Cells(1, g_offAssign_File) = strFile
.Cells(1, g_offAssign_RUFile) = rngData.Cells(1, g_offData_RUFile)
End With
End If
End If
'Flag the Row as updated
'rngData.Interior.Color = vbGreen
Next 'rngData
EndThis:
Set rngAdd = Nothing
Set rngData = Nothing
Exit Sub
Err_Handler:
Call ShowErrorMessage(Err, "Sub RollupData_ExtractCodes")
Resume EndThis
End Sub