Advertisement
Guest User

Untitled

a guest
Nov 14th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub DellMacro()
  2. Dim ws As Worksheet
  3. Dim wsSrc As Worksheet
  4. Dim wsTrg As Worksheet
  5. Dim lRow As Integer, lRowEmpty As Integer
  6. Dim pRow As Integer, pRowEmpty As Integer
  7. Dim TrgPasteRow As Integer
  8. Dim TrgPasteRowEnd As Integer
  9. Dim foundEmpty As Boolean
  10. Dim i As Integer
  11. Dim wb As Workbook
  12.  
  13.     Set wb = ActiveWorkbook
  14.    
  15.     Set wsSrc = wb.Sheets("PROJECT DATA")
  16.    
  17.     With wb
  18.         Set ws = .Sheets.Add
  19.         ws.Name = "BD_data"
  20.     End With
  21.    
  22.     With ws
  23.     'heading
  24.        .Range("A1") = "Target Language"
  25.         .Range("B1") = "Translator name"
  26.         .Range("C1") = "Task"
  27.         .Range("D1") = "Sub Description"
  28.         .Range("E1") = "Component"
  29.         .Range("F1") = "UOM"
  30.         .Range("G1") = "Project Name"
  31.         .Range("H1") = "Client Name"
  32.         .Range("I1") = "PO Owner"
  33.         .Range("J1") = "PO Contact"
  34.         .Range("K1") = "PM office"
  35.         .Range("L1") = "Start Date"
  36.         .Range("M1") = "Delivery Date"
  37.         .Range("N1") = "Start Week"
  38.         .Range("O1") = "Period"
  39.         .Range("P1") = "Project Type"
  40.         .Range("Q1") = "Project Status"
  41.         .Range("R1") = "PO Requested"
  42.         .Range("S1") = "Rates Type"
  43.         .Range("T1") = "Number of Units"
  44.         .Range("U1") = "MT Discount for new words in %"
  45.         .Range("V1") = "WWC (for reference)"
  46.         .Range("W1") = "Total WC excluding Perfect Matches"
  47.         .Range("X1") = "Organization"
  48.         .Range("a1").EntireRow.Font.Bold = True
  49.        
  50.         'find Language field and then assess size of the list
  51.                lRow = Application.Match("LANGUAGE", wb.Sheets("PROJECT DATA").Range("A1:A100"), 0)
  52.                
  53.                 i = 1
  54.                 foundEmpty = False
  55.                 Do While (i < 31 And foundEmpty = False)
  56.                     If Len(Trim(wb.Sheets("PROJECT DATA").Range("A" & lRow + i))) = 0 Then
  57.                         lRowEmpty = lRow + i
  58.                         foundEmpty = True
  59.                     End If
  60.                     i = i + 1
  61.                 Loop
  62.                 'find job's name
  63.                pRow = Application.Match("JOB", wb.Sheets("PROJECT DATA").Range("A1:A100"), 0)
  64.        
  65.                 'copy over data
  66.                TrgPasteRow = 2
  67.                 TrgPasteRowEnd = TrgPasteRow + lRowEmpty - lRow - 2
  68.                
  69.                 'lang
  70.                .Range("A" & TrgPasteRow & ":A" & TrgPasteRowEnd).Value = wb.Sheets("PROJECT DATA").Range("A" & lRow + 1 & ":A" & lRowEmpty - 1).Value
  71.                 'translator
  72.                .Range("B" & TrgPasteRow & ":B" & TrgPasteRowEnd).Value = wb.Sheets("PROJECT DATA").Range("J" & lRow + 1 & ":J" & lRowEmpty - 1).Value
  73.                 'GLO code
  74.                .Range("D" & TrgPasteRow & ":D" & TrgPasteRowEnd).Value = wb.Sheets("PROJECT DATA").Range("B" & Application.Match("LIOX GEMINI NUMBER", wb.Sheets("PROJECT DATA").Range("A1:A100"), 0)).Value
  75.                 'client
  76.                .Range("H" & TrgPasteRow & ":H" & TrgPasteRowEnd).Value = "Dell"
  77.                 'PO owner
  78.                .Range("I" & TrgPasteRow & ":I" & TrgPasteRowEnd).Value = "USA"
  79.                 'PO contact
  80.                .Range("J" & TrgPasteRow & ":J" & TrgPasteRowEnd).Value = "Blazejova, Zuzana"
  81.                 'Office
  82.                .Range("K" & TrgPasteRow & ":K" & TrgPasteRowEnd).Value = "ZLN"
  83.                 'Start date
  84.                .Range("L" & TrgPasteRow & ":L" & TrgPasteRowEnd).Value = Date
  85.                 'UOM
  86.                    For i = TrgPasteRow To TrgPasteRowEnd
  87.                         .Range("F" & i & ":F" & i).Formula = "=if(int(T" & i & ")<=1,""Hour"",""Word"")"
  88.                     Next
  89.                 'Component
  90.                    For i = TrgPasteRow To TrgPasteRowEnd
  91.                         .Range("E" & i & ":E" & i).Formula = "=if(int(T" & i & ")<=1,""N/A"",""Help/Doc/XML"")"
  92.                     Next
  93.                 'Task
  94.                    For i = TrgPasteRow To TrgPasteRowEnd
  95.                         .Range("C" & i & ":C" & i).Formula = "=if(int(T" & i & ")<=1,""Transl. Small Project"",if(isblank(U" & i & "),""Translation"",""MT-PE Premium""))"
  96.                     Next
  97.                 'Project type
  98.                .Range("P" & TrgPasteRow & ":P" & TrgPasteRowEnd).Value = "Solution"
  99.                 'Project STatus
  100.                .Range("Q" & TrgPasteRow & ":Q" & TrgPasteRowEnd).Value = "Production"
  101.                 'PO Requested
  102.                .Range("R" & TrgPasteRow & ":R" & TrgPasteRowEnd).Value = "N"
  103.                 'Rates Type
  104.                    For i = TrgPasteRow To TrgPasteRowEnd
  105.                         .Range("S" & i & ":S" & i).Formula = "=if(int(T" & i & ")<=1,""Standard Hourly"",if(isblank(U" & i & "),""Standard Doc/Help/html"",""MT_PE Premium Quality Doc/Help/html""))"
  106.                     Next
  107.                 'HB date
  108.                .Range("M" & TrgPasteRow & ":M" & TrgPasteRowEnd).Value = wb.Sheets("PROJECT DATA").Range("D" & Application.Match("Date", wb.Sheets("PROJECT DATA").Range("D1:D100"), 0) + 1).Value
  109.                 'HB date
  110.                .Range("N" & TrgPasteRow & ":N" & TrgPasteRowEnd).Formula = "=weeknum(today(),21)"
  111.                 'Period
  112.                .Range("O" & TrgPasteRow & ":O" & TrgPasteRowEnd).Value = DateSerial(Year(Date), Month(Date), 1)
  113.                 .Range("O" & TrgPasteRow & ":O" & TrgPasteRowEnd).NumberFormat = "mmm-yy"
  114.                 'Job's name
  115.                .Range("G" & TrgPasteRow & ":G" & TrgPasteRowEnd).Value = Mid(wb.Sheets("PROJECT DATA").Range("B" & pRow).Value, 2, 6)
  116.                 'Number of units
  117.                    For i = TrgPasteRow To TrgPasteRowEnd
  118.                         .Range("T" & i & ":T" & i).Formula = "=if(" & _
  119.                         wb.Sheets("PROJECT DATA").Range("C" & lRow + 1) & "*0.2+" & _
  120.                         wb.Sheets("PROJECT DATA").Range("D" & lRow + 1) & "*0.5+" & _
  121.                         wb.Sheets("PROJECT DATA").Range("E" & lRow + 1) & "*(1-U" & i & "/100)+" & _
  122.                         wb.Sheets("PROJECT DATA").Range("G" & lRow + 1) & "*0.2<100,0.5,if(" & _
  123.                         wb.Sheets("PROJECT DATA").Range("C" & lRow + 1) & "*0.2+" & _
  124.                         wb.Sheets("PROJECT DATA").Range("D" & lRow + 1) & "*0.5+" & _
  125.                         wb.Sheets("PROJECT DATA").Range("E" & lRow + 1) & "*(1-U" & i & "/100)+" & _
  126.                         wb.Sheets("PROJECT DATA").Range("G" & lRow + 1) & "*0.2<300,1," & _
  127.                         wb.Sheets("PROJECT DATA").Range("C" & lRow + 1) & "*0.2+" & _
  128.                         wb.Sheets("PROJECT DATA").Range("D" & lRow + 1) & "*0.5+" & _
  129.                         wb.Sheets("PROJECT DATA").Range("E" & lRow + 1) & "*(1-U" & i & "/100)+" & _
  130.                         wb.Sheets("PROJECT DATA").Range("G" & lRow + 1) & "*0.2))"
  131.                        
  132.                         'WWC for reference
  133.                        .Range("V" & i & ":V" & i).Formula = "=" & _
  134.                         wb.Sheets("PROJECT DATA").Range("C" & lRow + 1) & "*0.2+" & _
  135.                         wb.Sheets("PROJECT DATA").Range("D" & lRow + 1) & "*0.5+" & _
  136.                         wb.Sheets("PROJECT DATA").Range("E" & lRow + 1) & "*(1-U" & i & "/100)+" & _
  137.                         wb.Sheets("PROJECT DATA").Range("G" & lRow + 1) & "*0.2"
  138.                        
  139.                         'total WC excluding perfect matches
  140.                        .Range("W" & i & ":W" & i).Formula = "=" & _
  141.                         wb.Sheets("PROJECT DATA").Range("H" & lRow + 1) & "-" & wb.Sheets("PROJECT DATA").Range("B" & lRow + 1) & ""
  142.                        
  143.                         lRow = lRow + 1
  144.                     Next
  145.                    
  146.                 'Organization
  147.                .Range("X" & TrgPasteRow & ":X" & TrgPasteRowEnd).Value = wb.Sheets("PROJECT DATA").Range("B" & Application.Match("ORGANIZATION", wb.Sheets("PROJECT DATA").Range("A1:A100"), 0)).Value
  148.                 '.Sheets(1).Range("B" & NumOfRows & ":K" & NumOfRows + 31).PasteSpecial xlPasteFormulas
  149.                'TargetWb.Sheets(1).Range("B" & NumOfRows).Resize(30, 9) = .Range("A" & lRow + 1).Resize(30, 9)
  150.        
  151. '        For Each cell In TargetWb.Sheets(1).Range("L2:L" & NumOfRows)
  152. '            cell.Formula = "=D" & cell.Row & "*0.2+E" & cell.Row & "*0.5+F" & cell.Row & "+H" & cell.Row & "*0.2"
  153. '        Next cell
  154.  
  155.     End With
  156.    
  157.    
  158. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement