ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

VBA µe¹Ï¤è¦¡½Ð¯q?????

¦^´_ 1# iverson105

¿@ÁY³o¼Ë,¸Õ¸Õ¬Ý
Sub ALL_PLOT()
Dim x As Integer
Sheets("R2R_analysis").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
Application.ScreenUpdating = False
For x = 2 To Worksheets.Count
   ActiveChart.SeriesCollection.NewSeries
   ActiveChart.SeriesCollection(x - 1).Name = Sheets("¤u§@ªí1 (" & x & ")").Range("U1")
   ActiveChart.SeriesCollection(x - 1).XValues = Sheets("¤u§@ªí1 (" & x & ")").Range("A2:A20000")
   ActiveChart.SeriesCollection(x - 1).Values = Sheets("¤u§@ªí1 (" & x & ")").Range("D2:D20000")
Next
Application.ScreenUpdating = True

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.ApplyLayout (4)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim xRg As Range
Dim xChart As ChartObject
Set xRg = Range("A20:J50")
Set xChart = ActiveSheet.ChartObjects(1)
With xChart
   .Top = xRg(1).Top
   .Left = xRg(1).Left
   .Width = xRg.Width
   .Height = xRg.Height
End With

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.SetElement (msoElementChartTitleAboveChart)
Selection.Caption = "R2R_Ave.G.R."
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
Selection.Caption = "G.R.(mm/hr)"
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
Selection.Caption = "Length(mm)"
ActiveSheet.ChartObjects(1).Activate
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = 0
ActiveChart.Axes(xlCategory).MaximumScale = 1100
ActiveChart.Axes(xlCategory).MajorUnit = 100
ActiveChart.Axes(xlCategory).MinorUnit = 50
ActiveChart.Axes(xlCategory).CrossesAt = 0
ActiveChart.Axes(xlValue).CrossesAt = 0
ActiveChart.SetElement (msoElementPrimaryValueGridLinesMajor)
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMajor)
Application.ScreenUpdating = True
End Sub

TOP

¦^´_ 2# jcchiang
²Ä¤G­Ó°ÝÃD:¦pªG§Ú­nµe²Ä¤G±i¹Ï¦b¦P¤@±isheet¤º,À³¸Ó«ç»ò¼g(¸ê®Æ¤]¬O®Ú¾Ú¤§«eªºsheet ¦ý¤£¦Pcolumn)
¦]¬°¤£½T©w·|µe´X±i¹Ï,©Ò¥Hµ{¦¡·|¥ý¸ß°Ý­nµe´X¦¸(¦pªG¥u·|µe2±i´N±Ny = Application.InputBox("µe¹Ï¦¸¼Æ", "")²¾°£,For z = 1 To y§ï¬°For z = 1 To 2)
¥t¥~²Ä¤G±i¥H«áªº¹ÏColumn¤£ª¾¹D·|¦b­þ¸Ì,¥ý·í§@¦A²Ä¤@±i¹ÏColumn©¹¥kÂ\©ñ,¦pªG¦ì¸m®t²§¸û¦h´N­n¦A­×§ï

Sub ALL_PLOT1()
Dim x, y, z As Integer
y = Application.InputBox("µe¹Ï¦¸¼Æ", "")
For z = 1 To y
Sheets("R2R_analysis").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
Application.ScreenUpdating = False
For x = 2 To Worksheets.Count
   ActiveChart.SeriesCollection.NewSeries
   ActiveChart.SeriesCollection(x - 1).Name = Sheets("¤u§@ªí1 (" & x & ")").Range("U1").Offset(0, (z - 1))
   ActiveChart.SeriesCollection(x - 1).XValues = Sheets("¤u§@ªí1 (" & x & ")").Range("A2:A20000").Offset(0, (z - 1))
   ActiveChart.SeriesCollection(x - 1).Values = Sheets("¤u§@ªí1 (" & x & ")").Range("D2:D20000").Offset(0, (z - 1))
Next
Application.ScreenUpdating = True

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.ApplyLayout (4)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim xRg As Range
Dim xChart As ChartObject
Set xRg = Range("A20:J50")
Set xChart = ActiveSheet.ChartObjects(z)
With xChart
   .Top = xRg(z).Top
   .Left = xRg(z).Left
   .Width = xRg.Width
   .Height = xRg.Height
End With

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.SetElement (msoElementChartTitleAboveChart)
Selection.Caption = "R2R_Ave.G.R." & z
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
Selection.Caption = "G.R.(mm/hr)"
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
Selection.Caption = "Length(mm)"
ActiveSheet.ChartObjects(z).Activate
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = 0
ActiveChart.Axes(xlCategory).MaximumScale = 1100
ActiveChart.Axes(xlCategory).MajorUnit = 100
ActiveChart.Axes(xlCategory).MinorUnit = 50
ActiveChart.Axes(xlCategory).CrossesAt = 0
ActiveChart.Axes(xlValue).CrossesAt = 0
ActiveChart.SetElement (msoElementPrimaryValueGridLinesMajor)
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMajor)
Application.ScreenUpdating = True
Next
End Sub

TOP

¦^´_ 4# iverson105

³o¬q¬O¦b§ì¤u§@ªí¸ê®Æ¨ì¹Ïªí¸Ì
§Aªº¤u§@ªí¦WºÙ¬O"¤u§@ªí1 (2)",¤u§@ªí1 (3)"...........¥H¤W¶Ü??
,¥i¥H¤W¶Ç§AªºÀɮ׶Ü??³o¼Ë¤ñ¸û¯àª¾¹D­ì¦]

TOP

¦^´_ 6# iverson105

³o¼Ë¥¼ª¾ªºÅܼƤӦh¤F
1.·|µe´X±i¹Ï¤£ª¾
2.¦WºÙ¤S­n¤£¤@¼Ë
3.¨C±i¹Ï®y¼Ð¤S­n¤£¤@¼Ë
°£«D¬O¥ý±N¹Ïªí³]©w¦n­nªº¦WºÙ¸ò®y¼Ð¦A±N¸ê®Æ©ß¶i¥h,
¦pªG¬ÛÃö¸ê®Æ³£¤£©úªº±¡ªp¤U,¤p§Ì¤~²¨¾Ç²L¥i¯à¼g¤£¥X¨Ó,´N­n½Ð¯¸¤Wªº¤j¯««ü¾ÉÅo

TOP

¦^´_ 6# iverson105
¥ý¿é¤J©Ò»Ý¸ê®Æ«á,¦A±N¬ÛÃö¸ê®Æ±a¤J¹Ïªí
¦pªG¦³¤£°÷ªº½Ð¨Ì¦¹¤è¦¡¼W¥[­nªº¸ê®Æ

Sub ALL_PLOT2()
Dim x, y, z, R As Integer
Dim CName(10, 10)
R = 0

Do While y = ""                                          '¨¾¤î¸ê®Æ¬°ªÅ¥Õ
   y = Application.InputBox("µe¹Ï¦¸¼Æ", "", 1, 350, 150) '¿é¤J­nµe´X±i¹Ï,¹w³]¬°1±i
   If y = "" Then MsgBox "µe¹Ï¦¸¼Æ¤£±o¬°ªÅ¥Õ!!"
Loop
'----------------------------------¿é¤J¦U¹Ïªí¬ÛÃö¸ê®Æ(©Ò»Ý¸ê®Æ¦Û¦æ¼W¥[)-----------
For z = 1 To y
Do While CName(z, 0) = ""
   CName(z, 0) = Application.InputBox("²Ä" & z & "¹Ï¦W", "", "R2R_Ave.G.R." & z, 350, 150) '¿é¤J¹Ïªí¦WºÙ,¹w³]¬°R2R_Ave.G.R.1
   If CName(z, 0) = "" Then MsgBox "½Ð¿é¤J¹Ï¦W!!"
Loop
Do While CName(z, 1) = ""
   CName(z, 1) = Application.InputBox("²Ä" & z & "¹ÏªºMinimumScale", "", "0", 350, 150)    '¿é¤Jx¶b³Ì¤p®y¼Ð,¹w³]¬°0
   If CName(z, 1) = "" Then MsgBox "MinimumScale¤£±o¬°ªÅ¥Õ!!"
Loop
Do While CName(z, 2) = ""
   CName(z, 2) = Application.InputBox("²Ä" & z & "¹ÏªºMaximumScale", "", "1000", 350, 150) '¿é¤Jx¶b³Ì¤j®y¼Ð,¹w³]¬°0
   If CName(z, 2) = "" Then MsgBox "MaximumScale¤£±o¬°ªÅ¥Õ!!"
Loop
Next

'---------------------------------------------------------------
For z = 1 To y
Sheets("R2R_analysis").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
Application.ScreenUpdating = False
For x = 2 To Worksheets.Count
   ActiveChart.SeriesCollection.NewSeries
   ActiveChart.SeriesCollection(x - 1).Name = Sheets("¤u§@ªí1 (" & x & ")").Range("U1").Offset(0, (z - 1))
   ActiveChart.SeriesCollection(x - 1).XValues = Sheets("¤u§@ªí1 (" & x & ")").Range("A2:A20000").Offset(0, (z - 1))
   ActiveChart.SeriesCollection(x - 1).Values = Sheets("¤u§@ªí1 (" & x & ")").Range("D2:D20000").Offset(0, (z - 1))
Next
Application.ScreenUpdating = True

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.ApplyLayout (4)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim xRg As Range
Dim xChart As ChartObject
Set xRg = Range("A20:J50").Offset(0, R)
Set xChart = ActiveSheet.ChartObjects(z)
With xChart
   .Top = xRg(z).Top
   .Left = xRg(z).Left
   .Width = xRg.Width
   .Height = xRg.Height
End With

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveChart.SetElement (msoElementChartTitleAboveChart)
Selection.Caption = CName(z, 0)
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
Selection.Caption = "G.R.(mm/hr)"
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
Selection.Caption = "Length(mm)"
ActiveSheet.ChartObjects(z).Activate
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = CName(z, 1)
ActiveChart.Axes(xlCategory).MaximumScale = CName(z, 2)
ActiveChart.Axes(xlCategory).MajorUnit = 100
ActiveChart.Axes(xlCategory).MinorUnit = 50
ActiveChart.Axes(xlCategory).CrossesAt = 0
ActiveChart.Axes(xlValue).CrossesAt = 0
ActiveChart.SetElement (msoElementPrimaryValueGridLinesMajor)
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMajor)
Application.ScreenUpdating = True
R = R + 10 '¨C±i¹Ïªí¦ì¸m¶¡¹j
Next
End Sub

TOP

        ÀR«ä¦Û¦b : ¯à¥I¥X·R¤ß´N¬OºÖ¡A¯à®ø°£·Ð´o´N¬O¼z¡C
ªð¦^¦Cªí ¤W¤@¥DÃD