but when i use the code as follws,some questions happened:
Sub copyd()
Dim p, q
Columns("k:l").ClearContents
p = ActiveSheet.Cells.Rows.Count
q = ActiveSheet.Cells(p, 4).End(xlUp).Row
Range("D1
" & q - 1).Select
Selection.Copy
Range("K1").Select
ActiveSheet.Paste
Range("G1:G" & q - 1).Select
Application.CutCopyMode = False
Selection.Copy
Range("L1").Select
ActiveSheet.Paste
Dim chtChart As Chart
Set chtChart = Charts.Add
With chtChart
.SetSourceData Source:=ActiveSheet.[k1].CurrentRegion, PlotBy:=xlRows
.ChartType = xlColumnClustered
.HasDataTable = True
.ApplyDataLabels
.HasTitle = True
.ChartTitle.Text = "histogram"
.HasLegend = False
.Name = "histogram"
End With
Set chtChart = Nothing
End Sub
application alert:
20200827121045.png
histogram each colunm have space between each other,and the column have the some color,not the different colours:
20200827120955.png