South_Florida
New Member
- Joined
- Jun 1, 2016
- Messages
- 9
I'm having a bit of a difficult time creating a graph that I need. I want the x axis to begin at a value of 100 but I want the x-axis to read 500,1000,1500,2000, and 2500 at their respective tick marks. I do not want 100 to be shown on the scale but that is where the data is to start. My current code is as follows
ChDir "C:\Users\\Desktop"
fName = Application.GetOpenFilename()
Workbooks.OpenText Filename:=fName, _
Origin:=437, _
StartRow:=5, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1)), TrailingMinusNumbers:=True
Range("D1").Select
ActiveCell.FormulaR1C1 = _
"=(1/(INDEX(C[-3],(MATCH(MAX(C[-2]),C[-2],0)))))*10^7-((1/(RC[-3]:R[2999]C[-3]))*10^7)"
Range("D1").Select
Selection.AutoFill Destination:=Range("D1:D3000"), Type:=xlFillDefault
Range("D1:D3000").Select
Range("B1:B3000").Select
Range("B3000").Activate
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Range("C1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = ""
Columns("D:E").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Range("$D:$E")
ActiveChart.Axes(xlValue).MajorGridlines.Select
Selection.Format.Line.Visible = msoFalse
ActiveChart.Legend.Select
Selection.Delete
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MaximumScale = 25000
ActiveChart.Axes(xlValue).MaximumScale = 10000
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = -3000
ActiveChart.Axes(xlCategory).MinimumScale = 100
ActiveChart.Axes(xlCategory).MaximumScale = 4000
ActiveChart.Axes(xlCategory).MaximumScale = 2500
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MajorUnit = 500
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MajorUnit = 200
Range("A4").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.Paste
Selection.Format.TextFrame2.TextRange.Font.Size = 16
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Intensity (A/U)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Intensity (A/U)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 15).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 9).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(10, 6).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Raman Shift (cm^-1)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Raman Shift (cm^-1)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 19).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 19).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = "General"
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = 0
ActiveChart.Axes(xlCategory).CrossesAt = 100
ActiveChart.Axes(xlCategory).CrossesAt = 0
ActiveChart.Axes(xlCategory).MajorUnit = 500
End Sub
Obviously the last few lines of code won't give me the axis scale I require but that is where I am stumped. If anyone could help me out it would be greatly appreciated!
ChDir "C:\Users\\Desktop"
fName = Application.GetOpenFilename()
Workbooks.OpenText Filename:=fName, _
Origin:=437, _
StartRow:=5, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1)), TrailingMinusNumbers:=True
Range("D1").Select
ActiveCell.FormulaR1C1 = _
"=(1/(INDEX(C[-3],(MATCH(MAX(C[-2]),C[-2],0)))))*10^7-((1/(RC[-3]:R[2999]C[-3]))*10^7)"
Range("D1").Select
Selection.AutoFill Destination:=Range("D1:D3000"), Type:=xlFillDefault
Range("D1:D3000").Select
Range("B1:B3000").Select
Range("B3000").Activate
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Range("C1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = ""
Columns("D:E").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Range("$D:$E")
ActiveChart.Axes(xlValue).MajorGridlines.Select
Selection.Format.Line.Visible = msoFalse
ActiveChart.Legend.Select
Selection.Delete
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MaximumScale = 25000
ActiveChart.Axes(xlValue).MaximumScale = 10000
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = -3000
ActiveChart.Axes(xlCategory).MinimumScale = 100
ActiveChart.Axes(xlCategory).MaximumScale = 4000
ActiveChart.Axes(xlCategory).MaximumScale = 2500
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MajorUnit = 500
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MajorUnit = 200
Range("A4").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.Paste
Selection.Format.TextFrame2.TextRange.Font.Size = 16
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Intensity (A/U)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Intensity (A/U)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 15).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 9).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(10, 6).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Raman Shift (cm^-1)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Raman Shift (cm^-1)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 19).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 19).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 16
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.NumberFormat = "General"
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = 0
ActiveChart.Axes(xlCategory).CrossesAt = 100
ActiveChart.Axes(xlCategory).CrossesAt = 0
ActiveChart.Axes(xlCategory).MajorUnit = 500
End Sub
Obviously the last few lines of code won't give me the axis scale I require but that is where I am stumped. If anyone could help me out it would be greatly appreciated!