Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub fill_art_vol()
- Application.ScreenUpdating = False
- On Error Resume Next
- Dim t As Single
- t = Timer
- Dim answer As VbMsgBoxResult
- answer = MsgBox("Do you want to fill article volumes?", vbYesNo, "Run Macro")
- If answer = vbYes Then
- Dim WS_Count As Integer
- Dim i As Integer
- Dim x As Integer
- Dim art As Long
- Dim rows As Integer
- Dim current_workbook As Workbook
- Dim art_workbook As Workbook
- Dim find_col As Integer
- Dim find_art As Integer
- Set current_workbook = ActiveWorkbook
- Set art_workbook = Workbooks("Ñïðàâêà Öåíòðàëíè ðàçïðåäåëåíèÿ.xlsx")
- If art_workbook.ActiveSheet.FilterMode = True Then
- art_workbook.ActiveSheet.ShowAllData
- End If
- WS_Count = ActiveWorkbook.Worksheets.Count
- For i = 1 To WS_Count
- ActiveWorkbook.Worksheets(i).Select
- If ActiveSheet.FilterMode = True Then
- ActiveSheet.ShowAllData
- End If
- If Range("A2") = "" Then
- Range("B2").Select
- rows = Range(Selection, Selection.End(xlDown)).Count + 1
- For x = 1 To rows
- If Range("F" & x) = "TOTAL" Then
- art = Range("B" & x).Value
- If Not art_workbook.ActiveSheet.Range("E:E").Find(What:=art, LookIn:=xlValues) Is Nothing Then
- found_art = art_workbook.ActiveSheet.Range("E:E").Find(What:=art, LookIn:=xlValues).Row
- art_workbook.ActiveSheet.Range("R" & found_art).Value = Cells(x, "J").Value
- art_workbook.ActiveSheet.Range("S" & found_art).Value = Cells(x, "K").Value
- art_workbook.ActiveSheet.Range("T" & found_art).Value = Cells(x, "M").Value
- art_workbook.ActiveSheet.Range("U" & found_art).Value = Cells(x, "O").Value
- art_workbook.ActiveSheet.Range("V" & found_art).Value = Cells(x, "P").Value
- art_workbook.ActiveSheet.Range("A" & found_art, "V" & found_art).Interior.Color = RGB(146, 208, 80)
- Else
- MsgBox ("Article " & art & " not found")
- End If
- End If
- Next x
- Else
- art = ActiveSheet.Name
- find_col = Range("5:5").Find(What:="Íàëè÷íîñò âúâ ôèëèàëà", LookIn:=xlValues).Column
- If Not art_workbook.ActiveSheet.Range("E:E").Find(What:=art, LookIn:=xlValues) Is Nothing Then
- found_art = art_workbook.ActiveSheet.Range("E:E").Find(What:=art, LookIn:=xlValues).Row
- art_workbook.ActiveSheet.Range("R" & found_art, "V" & found_art).Value = Range(Cells(7, find_col), Cells(7, find_col + 4)).Value
- art_workbook.ActiveSheet.Range("A" & found_art, "V" & found_art).Interior.Color = RGB(146, 208, 80)
- Else
- MsgBox ("Article " & art & " not found")
- End If
- End If
- Next i
- End If
- Application.CutCopyMode = False
- MsgBox "The task is completed in " & Round(Timer - t, 0) & "s"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement