snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Dim PlanChart As String
Dim Titulo As String
Dim AreaSheett As String
Dim AreaSheettt As String
PlanChart = Sheet2.Name
Dim Linha As Double
Linha = 4
With Planilhal
Do
Linha = Linha + 1
Loop Until .Cells(Linha, 2).Value = ""
End With
Linha = Linha - 1
Dim Sheett As Chart
Set Sheett = Sheets(PlanChart).ChartObjects("Chart 1").Chart
If ComboBox1.Value = "2561" Then
Titulo = Sheet1.Range("A2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range("A3:A & Linha").Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range("B3:B & Linha ").Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = "2562" Then
Titulo = Sheet1.Range("D2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range("D3:D & Linha ").Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range("E3:E & Linha ").Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = "2563" Then
Titulo = Sheet1.Range("G2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range("G3:G & Linha ").Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range("H3:H& Linha ").Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
Call Carreger_Chart
Exit Sub
Erro:
MsgBox " Erro! ", vbCritical, " ERRO "
End Sub
Private Sub UserForm_Initialize()
Call Carreger_Chart
ComboBox1.AddItem " 2561 "
ComboBox1.AddItem " 2562 "
ComboBox1.AddItem " 2563 "
End Sub
มันติดเหลือง Loop Until .Cells(Linha, 2).Value = "" บรรทัดนี้ และขึ้น Run time error 424 : Object Required
You do not have the required permissions to view the files attached to this post.
Private Sub ComboBox1_Change()
'On Error GoTo Erro
Dim PlanChart As String
Dim Titulo As String
Dim AreaSheett As String
Dim AreaSheettt As String
PlanChart = Sheet2.Name
Dim Linha As Double
Linha = 4
With Worksheet(PlanChart)
Do
Linha = Linha + 1
Loop Until .Cells(Linha, 2).Value = ""
End With
Dim Sheett As Chart
Set Sheett = Sheets(PlanChart).ChartObjects(" Chart 1 ").Chart
If ComboBox1.Value = " 2561 " Then
Titulo = Sheet1.Range("A2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" A3:A " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" B3:B " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = " 2562 " Then
Titulo = " 2562 "
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" D3:D " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" E3:E " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = " 2563 " Then
Titulo = Sheet1.Range("G2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" G3:G " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" H3:H " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
Call Carreger_Chart
Exit Sub
Erro:
MsgBox " Erro! ", vbCritical, " ERRO "
End Sub
[/coed]
You do not have the required permissions to view the files attached to this post.
Private Sub ComboBox1_Change()
'On Error GoTo Erro
Dim PlanChart As String
Dim Titulo As String
Dim AreaSheett As String
Dim AreaSheettt As String
PlanChart = Sheet2.Name
Dim Linha As Double
Linha = 4
With Worksheet(PlanChart)
Do
Linha = Linha + 1
Loop Until .Cells(Linha, 2).Value = ""
End With
Dim Sheett As Chart
Set Sheett = Sheets(PlanChart).ChartObjects(" Chart 1 ").Chart
If ComboBox1.Value = " 2561 " Then
Titulo = Sheet1.Range("A2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" A3:A " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" B3:B " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = " 2562 " Then
Titulo = " 2562 "
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" D3:D " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" E3:E " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
If ComboBox1.Value = " 2563 " Then
Titulo = Sheet1.Range("G2").Value
AreaSheettt = " = " & Sheet1.Name & " ! " & Sheet1.Range(" G3:G " & Linha).Address
AreaSheett = " = " & Sheet1.Name & " ! " & Sheet1.Range(" H3:H " & Linha).Address
With Sheett
.HasTitle = True
.ChartTitle.Text = Titulo
.SeriesCollection(1).XValues = AreaSheettt
.SeriesCollection(1).Values = AreaSheett
End With
End If
Call Carreger_Chart
Exit Sub
Erro:
MsgBox " Erro! ", vbCritical, " ERRO "
End Sub
[/coed]
You do not have the required permissions to view the files attached to this post.