Update CSV columns to I-R (was G-P)
This commit is contained in:
@@ -233,16 +233,16 @@ NextCsvLine:
|
|||||||
wsTarget.Cells(writeRow, 3).Value = code
|
wsTarget.Cells(writeRow, 3).Value = code
|
||||||
|
|
||||||
' CSV col 2-11 -> G-P column
|
' CSV col 2-11 -> G-P column
|
||||||
If UBound(dataArray) >= 1 Then wsTarget.Cells(writeRow, 7).Value = CleanCSVField(CStr(dataArray(1)))
|
If UBound(dataArray) >= 1 Then wsTarget.Cells(writeRow, 9).Value = CleanCSVField(CStr(dataArray(1)))
|
||||||
If UBound(dataArray) >= 2 Then wsTarget.Cells(writeRow, 8).Value = CleanCSVField(CStr(dataArray(2)))
|
If UBound(dataArray) >= 2 Then wsTarget.Cells(writeRow, 10).Value = CleanCSVField(CStr(dataArray(2)))
|
||||||
If UBound(dataArray) >= 3 Then wsTarget.Cells(writeRow, 9).Value = CleanCSVField(CStr(dataArray(3)))
|
If UBound(dataArray) >= 3 Then wsTarget.Cells(writeRow, 11).Value = CleanCSVField(CStr(dataArray(3)))
|
||||||
If UBound(dataArray) >= 4 Then wsTarget.Cells(writeRow, 10).Value = CleanCSVField(CStr(dataArray(4)))
|
If UBound(dataArray) >= 4 Then wsTarget.Cells(writeRow, 12).Value = CleanCSVField(CStr(dataArray(4)))
|
||||||
If UBound(dataArray) >= 5 Then wsTarget.Cells(writeRow, 11).Value = CleanCSVField(CStr(dataArray(5)))
|
If UBound(dataArray) >= 5 Then wsTarget.Cells(writeRow, 13).Value = CleanCSVField(CStr(dataArray(5)))
|
||||||
If UBound(dataArray) >= 6 Then wsTarget.Cells(writeRow, 12).Value = CleanCSVField(CStr(dataArray(6)))
|
If UBound(dataArray) >= 6 Then wsTarget.Cells(writeRow, 14).Value = CleanCSVField(CStr(dataArray(6)))
|
||||||
If UBound(dataArray) >= 7 Then wsTarget.Cells(writeRow, 13).Value = CleanCSVField(CStr(dataArray(7)))
|
If UBound(dataArray) >= 7 Then wsTarget.Cells(writeRow, 15).Value = CleanCSVField(CStr(dataArray(7)))
|
||||||
If UBound(dataArray) >= 8 Then wsTarget.Cells(writeRow, 14).Value = CleanCSVField(CStr(dataArray(8)))
|
If UBound(dataArray) >= 8 Then wsTarget.Cells(writeRow, 16).Value = CleanCSVField(CStr(dataArray(8)))
|
||||||
If UBound(dataArray) >= 9 Then wsTarget.Cells(writeRow, 15).Value = CleanCSVField(CStr(dataArray(9)))
|
If UBound(dataArray) >= 9 Then wsTarget.Cells(writeRow, 17).Value = CleanCSVField(CStr(dataArray(9)))
|
||||||
If UBound(dataArray) >= 10 Then wsTarget.Cells(writeRow, 16).Value = CleanCSVField(CStr(dataArray(10)))
|
If UBound(dataArray) >= 10 Then wsTarget.Cells(writeRow, 18).Value = CleanCSVField(CStr(dataArray(10)))
|
||||||
|
|
||||||
' Auto-fill D, E columns
|
' Auto-fill D, E columns
|
||||||
Call FillFromKukanMaster(wsTarget, writeRow, False)
|
Call FillFromKukanMaster(wsTarget, writeRow, False)
|
||||||
@@ -284,30 +284,31 @@ Sub validateDetailData(ByVal ws As Worksheet, ByVal rowNum As Long)
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Check J, K required and numeric
|
' Check G, H required and numeric (for composite key)
|
||||||
|
If Trim(ws.Cells(rowNum, 9).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 9).Value) Then
|
||||||
|
ws.Cells(rowNum, 17).Value = "G column (I) is required and must be numeric"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
If Trim(ws.Cells(rowNum, 10).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 10).Value) Then
|
If Trim(ws.Cells(rowNum, 10).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 10).Value) Then
|
||||||
ws.Cells(rowNum, 17).Value = "J column is required and must be numeric"
|
ws.Cells(rowNum, 17).Value = "H column (J) is required and must be numeric"
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Trim(ws.Cells(rowNum, 11).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 11).Value) Then
|
' Check I (K column) required
|
||||||
ws.Cells(rowNum, 17).Value = "K column is required and must be numeric"
|
If Trim(ws.Cells(rowNum, 11).Value) = "" Then
|
||||||
|
ws.Cells(rowNum, 17).Value = "I column (K) is required"
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Check G, H, I required and numeric
|
' Check J, K required and numeric
|
||||||
If Trim(ws.Cells(rowNum, 7).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 7).Value) Then
|
If Trim(ws.Cells(rowNum, 12).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 12).Value) Then
|
||||||
ws.Cells(rowNum, 17).Value = "G column is required and must be numeric"
|
ws.Cells(rowNum, 17).Value = "J column (L) is required and must be numeric"
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Trim(ws.Cells(rowNum, 8).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 8).Value) Then
|
If Trim(ws.Cells(rowNum, 13).Value) = "" Or Not IsNumeric(ws.Cells(rowNum, 13).Value) Then
|
||||||
ws.Cells(rowNum, 17).Value = "H column is required and must be numeric"
|
ws.Cells(rowNum, 17).Value = "K column (M) is required and must be numeric"
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Trim(ws.Cells(rowNum, 9).Value) = "" Then
|
|
||||||
ws.Cells(rowNum, 17).Value = "I column is required"
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@@ -315,31 +316,30 @@ Sub validateDetailData(ByVal ws As Worksheet, ByVal rowNum As Long)
|
|||||||
Dim col As Long
|
Dim col As Long
|
||||||
Dim colName As String
|
Dim colName As String
|
||||||
Dim colLetter As String
|
Dim colLetter As String
|
||||||
colLetter = "LMNOP"
|
colLetter = "NOPQR"
|
||||||
|
|
||||||
For col = 12 To 16
|
For col = 14 To 18
|
||||||
If Trim(ws.Cells(rowNum, col).Value) <> "" And Not IsNumeric(ws.Cells(rowNum, col).Value) Then
|
If Trim(ws.Cells(rowNum, col).Value) <> "" And Not IsNumeric(ws.Cells(rowNum, col).Value) Then
|
||||||
colName = Mid(colLetter, col - 11, 1)
|
colName = Mid(colLetter, col - 13, 1)
|
||||||
ws.Cells(rowNum, 17).Value = colName & " column must be numeric"
|
ws.Cells(rowNum, 17).Value = colName & " column must be numeric"
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
Next col
|
Next col
|
||||||
|
|
||||||
' Check GHI composite key duplicate
|
' Check GH composite key duplicate
|
||||||
Dim g As String, h As String, i As String
|
Dim g As String, h As String
|
||||||
Dim r As Long
|
Dim r As Long
|
||||||
Dim lastRow As Long
|
Dim lastRow As Long
|
||||||
|
|
||||||
g = Trim(ws.Cells(rowNum, 7).Value)
|
g = Trim(ws.Cells(rowNum, 9).Value)
|
||||||
h = Trim(ws.Cells(rowNum, 8).Value)
|
h = Trim(ws.Cells(rowNum, 10).Value)
|
||||||
|
|
||||||
lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
|
lastRow = ws.Cells(ws.Rows.Count, 3).End(xlUp).Row
|
||||||
|
|
||||||
For r = 7 To lastRow
|
For r = 7 To lastRow
|
||||||
If r <> rowNum And Trim(ws.Cells(r, 3).Value) = Trim(ws.Cells(rowNum, 3).Value) Then
|
If r <> rowNum And Trim(ws.Cells(r, 3).Value) = Trim(ws.Cells(rowNum, 3).Value) Then
|
||||||
If Trim(ws.Cells(r, 7).Value) = g And _
|
If Trim(ws.Cells(r, 9).Value) = g And Trim(ws.Cells(r, 10).Value) = h Then
|
||||||
Trim(ws.Cells(r, 8).Value) = h Then
|
ws.Cells(rowNum, 17).Value = "GH (I,J) combination already exists"
|
||||||
ws.Cells(rowNum, 17).Value = "GH combination already exists"
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
@@ -347,9 +347,9 @@ Sub validateDetailData(ByVal ws As Worksheet, ByVal rowNum As Long)
|
|||||||
|
|
||||||
' Validation passed
|
' Validation passed
|
||||||
ws.Cells(rowNum, 17).ClearContents
|
ws.Cells(rowNum, 17).ClearContents
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
' Button macro (Validate selected row)
|
' Button macro (Validate selected row)
|
||||||
Sub validateDetailDataButton()
|
Sub validateDetailDataButton()
|
||||||
Dim ws As Worksheet
|
Dim ws As Worksheet
|
||||||
@@ -418,8 +418,8 @@ Sub ExportMasterDetailData()
|
|||||||
rowCount = rowCount + 1
|
rowCount = rowCount + 1
|
||||||
' CSV col1 -> C column
|
' CSV col1 -> C column
|
||||||
csvContent = csvContent & CleanCSVField(ws.Cells(r, 3).Value)
|
csvContent = csvContent & CleanCSVField(ws.Cells(r, 3).Value)
|
||||||
' CSV col2-11 -> G-P column
|
' CSV col2-11 -> I-R column
|
||||||
For j = 7 To 16
|
For j = 9 To 18
|
||||||
csvContent = csvContent & "," & CleanCSVField(ws.Cells(r, j).Value)
|
csvContent = csvContent & "," & CleanCSVField(ws.Cells(r, j).Value)
|
||||||
Next j
|
Next j
|
||||||
csvContent = csvContent & vbLf
|
csvContent = csvContent & vbLf
|
||||||
|
|||||||
Reference in New Issue
Block a user