title: Improve the speed and shorten the code for excel VBA MACRO
body: <p>I am very new on working with VBA and I wrote the code for a macro that initially build 16 charts and then exports the charts in .jpeg format. 
  The code is not to difficult to understand. 
  There are only some small differences on data to be selected, the name of the charts, and the position of the chart in the workbook. 
  Its basically  almost the same code multiplied 16 times for creating charts and another 16 times for exporting them.</p>
  
  <p>The code works fine but is taking around 20- 30 seconds to run.
  Do you have any Ideas on how I make it run faster?.</p>
  
  <p>Any input is welcomed. Thank you for your time.</p>
  
  <p><strong>First part for creating the charts</strong></p>
  
  <pre><code>Sub Export()
  
  Dim objChrt As ChartObject
  Dim myChart As Chart
  Dim sh As Worksheet
  
  ThisWorkbook.Sheets(1).Name = "Sheet1"
  Set sh = ActiveWorkbook.Worksheets("Sheet1")
  
  'S11-S14
  Set mychrt = sh.Shapes.AddChart.Chart
  Set chrta = sh.Shapes.AddChart.Chart
  Set chrtb = sh.Shapes.AddChart.Chart
  Set chrtc = sh.Shapes.AddChart.Chart
  
  'S21-S24
  Set chrtd = sh.Shapes.AddChart.Chart
  Set chrte = sh.Shapes.AddChart.Chart
  Set chrtf = sh.Shapes.AddChart.Chart
  Set chrtg = sh.Shapes.AddChart.Chart
  
  'S31-S34
  Set chrth = sh.Shapes.AddChart.Chart
  Set chrti = sh.Shapes.AddChart.Chart
  Set chrtj = sh.Shapes.AddChart.Chart
  Set chrtk = sh.Shapes.AddChart.Chart
  
  'S41-S44
  Set chrtl = sh.Shapes.AddChart.Chart
  Set chrtm = sh.Shapes.AddChart.Chart
  Set chrtn = sh.Shapes.AddChart.Chart
  Set chrto = sh.Shapes.AddChart.Chart
  
  '/////////S11-S14\\\\\\\\\\\\
  With mychrt
  'S11
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$C$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$C$807:$C$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 3 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S11"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 10
  .ChartArea.Left = 1700
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrta
  'S12
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$E$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$E$807:$E$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit (Green)
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S12"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 10
  .ChartArea.Left = 2460
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtb
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$g$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$g$807:$g$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S13"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 10
  .ChartArea.Left = 3220
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtc
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$i$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$i$807:$i$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S14"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 10
  .ChartArea.Left = 3980
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  '/////////S21-S24\\\\\\\\\\\\
  
  With chrtd
  'S21
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$k$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$k$807:$k$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S21"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 420
  .ChartArea.Left = 1700
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrte
  'S22
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$m$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$m$807:$m$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 3 'change to suit (Green)
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S22"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 420
  .ChartArea.Left = 2460
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtf
  'S23
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$o$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$o$807:$o$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S23"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 420
  .ChartArea.Left = 3220
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtg
  'S24
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$q$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$q$807:$q$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S24"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 420
  .ChartArea.Left = 3980
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  '/////////S31-S34\\\\\\\\\\\\
  
  With chrth
  'S31
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$s$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$s$807:$s$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S31"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 830
  .ChartArea.Left = 1700
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrti
  'S32
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$u$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$u$807:$u$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit (Green)
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S32"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 830
  .ChartArea.Left = 2460
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtj
  'S33
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$w$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$w$807:$w$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 3 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S33"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 830
  .ChartArea.Left = 3220
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtk
  'S34
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$y$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$y$807:$y$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 43 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S34"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 830
  .ChartArea.Left = 3980
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  '/////////S41-S44\\\\\\\\\\\\
  
  With chrtl
  'S41
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$AA$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$AA$807:$AA$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S41"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 1240
  .ChartArea.Left = 1700
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtm
  'S42
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$ac$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$ac$807:$ac$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit (Green)
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S42"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 1240
  .ChartArea.Left = 2460
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrtn
  'S43
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$ae$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$ae$807:$ae$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 41 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S43"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 1240
  .ChartArea.Left = 3220
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  
  With chrto
  'S44
  ' Chart type and source selection
  .ChartType = xlXYScatterSmoothNoMarkers
  .SeriesCollection.NewSeries
  .SeriesCollection(1).Name = "=Sheet1!$ag$5"
  .SeriesCollection(1).XValues = "=Sheet1!$B$807:$B$1006"
  .SeriesCollection(1).Values = "=Sheet1!$ag$807:$ag$1006"
  
  ' Color
  .SeriesCollection(1).Border.ColorIndex = 3 'change to suit
  
  ' Titles
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Text = "Gain(dB)"
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Frequency (Hz)"
  .HasTitle = True
  .ChartTitle.Text = "S44"
  
  ' Scale settings
  .Axes(xlCategory).Select
  .Axes(xlCategory).MinimumScale = 2400000000#
  .Axes(xlCategory).MaximumScale = 2500000000#
  .Axes(xlCategory).HasMajorGridlines = True
   Selection.TickLabelPosition = xlLow
  .Axes(xlValue).Select
  .Axes(xlValue).MinimumScale = -40
  .Axes(xlValue).MaximumScale = 0
  .Axes(xlValue).HasMajorGridlines = True
  
  ' Position and size
  .ChartArea.Top = 1240
  .ChartArea.Left = 3980
  .ChartArea.Height = 400
  .ChartArea.Width = 750
  End With
  </code></pre>
  
  <p><strong>Second part for exporting the charts</strong></p>
  
  <pre><code>Set objChrt = ActiveSheet.ChartObjects(1)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S11.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(2)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S12.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(3)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S13.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(4)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S14.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(5)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S21.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(6)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S22.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(7)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S23.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(8)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S24.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(9)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S31.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(10)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S32.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(11)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S33.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(12)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S34.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
   Set objChrt = ActiveSheet.ChartObjects(13)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S41.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(14)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S42.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(15)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S43.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  Set objChrt = ActiveSheet.ChartObjects(16)
  Set myChart = objChrt.Chart
  myFileName = ActiveWorkbook.Name &amp; " " &amp; "S44.JPEG"
  On Error Resume Next
  Kill ActiveWorkbook.Path &amp; "\" &amp; myFileName
  On Error GoTo 0
  myChart.Export Filename:=ActiveWorkbook.Path &amp; "\" &amp; myFileName, Filtername:="JPEG"
  
  MsgBox "OK"
  
  End Sub
  </code></pre>