Обсуждение портала:Кино/Динамика выхода фильмов СССР и СНГ по годам

message: Sub CCCP()
     oldmovies = Sheets(1).Range("a1").Value
     With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\1.txt", Destination:=Range("A1"))
         .Name = "1"
         .FieldNames = True
         .RowNumbers = False
         .FillAdjacentFormulas = False
         .PreserveFormatting = True
         .RefreshOnFileOpen = False
         .RefreshStyle = xlInsertDeleteCells
         .SavePassword = False
         .SaveData = True
         .AdjustColumnWidth = True
         .RefreshPeriod = 0
         .TextFilePromptOnRefresh = False
         .TextFilePlatform = 1251
         .TextFileStartRow = 1
         .TextFileParseType = xlDelimited
         .TextFileTextQualifier = xlTextQualifierDoubleQuote
         .TextFileConsecutiveDelimiter = True
         .TextFileTabDelimiter = False
         .TextFileSemicolonDelimiter = False
         .TextFileCommaDelimiter = False
         .TextFileSpaceDelimiter = False
         .TextFileOtherDelimiter = "["
         .TextFileColumnDataTypes = Array(1, 1)
         .TextFileTrailingMinusNumbers = True
         .Refresh BackgroundQuery:=False
     End With
 
     Columns("C:C").Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
         DataOption1:=xlSortNormal
 
         If Sheets(2).Name = "diag" Then Sheets(2).Delete
 
     Application.ScreenUpdating = False
     Count = 0
     For n = 1 To 10000
         cvalue = Sheets(1).Range("c" & n).Value
         If Left(cvalue, 1) = 1 Or Left(cvalue, 1) = 2 Then Count = Count + 1
         Sheets(1).Range("C" & n).Value = Left(Sheets(1).Range("C" & n).Value, 4)
     Next n
     Sheets(1).Range("A1").Value = Count
 
     firstyear = Sheets(1).Range("c1").Value
     lastyear = Sheets(1).Range("c" & Count).Value
     Sheets(2).Select
     Sheets(2).Activate
     firstyear2 = firstyear - 1
     rangeyear = lastyear - firstyear + 1
     For n = 1 To rangeyear
         Sheets(2).Range("a" & n).Value = firstyear2 + 1
         firstyear2 = firstyear2 + 1
     Next n
 
     For n = 1 To rangeyear
         Sheets(2).Range("c" & n).Value = 0
     Next n
 
     If Sheets(2).Range("b1").Value > 0 Then
             For n = 1 To rangeyear
                 Sheets(2).Range("c" & n).Value = Sheets(2).Range("b" & n).Value
             Next n
     End If
 
     For n = 1 To rangeyear
         Sheets(2).Range("b" & n).Value = 1
     Next n
 
     For n = 1 To Count
         If Sheets(1).Range("c" & n).Value = Sheets(1).Range("c" & (n + 1)).Value Then
                 For m = 1 To rangeyear
                     If Sheets(2).Range("a" & m).Value = Sheets(1).Range("c" & n).Value Then
                         Sheets(2).Range("b" & m).Value = Sheets(2).Range("b" & m).Value + 1
                     End If
                 Next m
         End If
     Next n
 
     Charts.Add
     ActiveChart.ChartType = xlLine
     ActiveChart.SetSourceData Source:=Sheets("Лист2").Range("A1:C" & rangeyear), PlotBy:= _
         xlColumns
     ActiveChart.SeriesCollection(1).Delete
     ActiveChart.SeriesCollection(1).XValues = "=Лист2!C1"
     ActiveChart.SeriesCollection(1).Name = "=""Текущее состояние"""
     ActiveChart.SeriesCollection(2).XValues = "=Лист2!C1"
     ActiveChart.SeriesCollection(2).Name = "=""Предыдущее состояние" & Chr(10) & oldmovies & " фильмов" & """"
     ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="diag"
     With ActiveChart
         .HasTitle = True
         .ChartTitle.Characters.Text = "Динамика выхода фильмов СНГ и СССР" & Chr(10) & Count & " фильмов."
         .Axes(xlCategory, xlPrimary).HasTitle = True
         .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "годы"
         .Axes(xlValue, xlPrimary).HasTitle = True
         .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "фильмы"
     End With
 
     ActiveChart.PlotArea.Select
     With Selection.Border
         .ColorIndex = 16
         .Weight = xlThin
         .LineStyle = xlContinuous
     End With
     Selection.Interior.ColorIndex = xlNone
     ActiveChart.SeriesCollection(2).Select
     With Selection.Border
         .ColorIndex = 32
         .Weight = xlThick
         .LineStyle = xlContinuous
     End With
     With Selection
         .MarkerBackgroundColorIndex = xlNone
         .MarkerForegroundColorIndex = xlNone
         .MarkerStyle = xlNone
         .Smooth = True
         .MarkerSize = 3
         .Shadow = False
     End With
     ActiveChart.ChartGroups(1).SeriesCollection(2).PlotOrder = 1
     ActiveChart.SeriesCollection(2).Select
     With Selection.Border
         .ColorIndex = 3
         .Weight = xlThick
         .LineStyle = xlContinuous
     End With
     With Selection
         .MarkerBackgroundColorIndex = xlNone
         .MarkerForegroundColorIndex = xlNone
         .MarkerStyle = xlNone
         .Smooth = True
         .MarkerSize = 3
         .Shadow = False
     End With
     ActiveChart.Axes(xlCategory).Select
     With Selection.TickLabels
         .Alignment = xlCenter
         .Offset = 100
         .ReadingOrder = xlContext
         .Orientation = xlUpward
     End With
 
     ActiveChart.Axes(xlCategory).Select
     With ActiveChart.Axes(xlCategory)
         .CrossesAt = 1
         .TickLabelSpacing = 4
         .TickMarkSpacing = 1
         .AxisBetweenCategories = True
         .ReversePlotOrder = False
     End With
 
     ActiveChart.Legend.Select
     Selection.Top = 147
     Selection.Height = 91
     Selection.Width = 96
     Selection.Left = 620
     ActiveChart.PlotArea.Width = 589
 End Sub
thread_title:  VBA скрипт, версия 20060315