Fixer l'unité principale de l'axe x du graphe
F
Bonjour :
Je voudrais mettre l'unité principale de l'axe x du graphe affiché à 7 jours. Mais il revoie une erreur à la ligne :
.Axes(xlCategory).MajorUnit = 7
Tout le reste du code fonctionne bien.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim ligneCount, columnCount As Long
Dim R As Range
Dim Ch As Shape
ligneCount = Range("B" & Rows.Count).End(xlUp).Row
If Target.Column = 2 And Target.Row > 4 And Target.Row <= ligneCount Then
ExcelGooglePHRASESearch ActiveCell.Value
End If
Dim X As Range, Y As Range
Dim Sh As Shape
columnCount = Cells(4, Columns.Count).End(xlToLeft).Column
If Target.Column = 1 And Target.Row > 4 And Target.Row <= ligneCount Then
Application.ScreenUpdating = False
With Workbooks("Donnees-Positionnemnt.xlsm").Sheets("Données générales")
Set X = .Range(Cells(4, 3), Cells(4, columnCount))
Set Y = .Range(Cells(ActiveCell.Row, 3), Cells(ActiveCell.Row, columnCount))
Set Sh = .Shapes.AddChart
End With
With Sh.Chart
.ChartArea.ClearContents
.ChartType = xlLineMarkers
.Axes(xlValue).ReversePlotOrder = True
.Axes(xlCategory).MajorUnit = 7
.HasTitle = True
.ChartTitle.Caption = """" & Workbooks("Donnees-Positionnemnt.xlsm").Sheets("Données générales").Cells(ActiveCell.Row, 2) & """"
With .SeriesCollection.NewSeries
.Name = "Positionnement"
.XValues = X
.Values = Y
End With
End With
Set Sh = Nothing
Set X = Nothing
Set Y = Nothing
End If
End Sub
Function ExcelGooglePHRASESearch(valeur)
Dim search_http As Object
Dim results_var As String
Dim search_url As String
With Sheets("Données générales")
search_url = "https://www.google.fr/search?sclient=psy-ab&hl=fr&site=webhp&source=hp&q=" & valeur
Set search_http = CreateObject("microsoft.xmlhttp")
'InputBox "URL:", "URL", search_url
With search_http
.Open "get", search_url, False
' tres souvent on est obligé de faire l'entete de la requete mais dans ce cas present non alors j'ai bloquer les lignes mais c'est juste pour information
' .SetRequestHeader "Accept", " text/html, application/xhtml+xml, */*"
' .SetRequestHeader "Accept-Language", "fr-FR"
' .SetRequestHeader "User-Agent", " Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"
' .SetRequestHeader "Accept-E ncoding", "gzip, deflate"
' .SetRequestHeader "Host", "www.google.fr"
' .SetRequestHeader "DNT", 1
' .SetRequestHeader "Connection", "Keep - Alive"
search_http.Send
results_var = CStr(search_http.responsetext)
End With
End With
'on place le code html de la requete dans un document html virtuel
'
With CreateObject("htmlfile")
.write results_var
MsgBox .getelementbyid("resultStats").innertext
'dans ce bloc with tu peut disséquer ta page comme si c'etait IE et récupérer tout les titre des proposition par exemple
End With
End Function
Merci d'avance.