Bedankt! Maar ik wil de cel geen naam geven, ik wil weten welk celnummer dit is (bijv. A3) om daarna een naam te definiëren als volgt:
Als ik de code zoals hierboven gebruik, komt er in de naamsdefinitie "Begin" en "Eind" te staan i.p.v. celnummer.
Code:
Sub Test()
With Sheets("Stroomverbruik")
begindatum = Application.InputBox("title", "title2", FormatDateTime(Date, vbShortDate), Type:=1)
If begindatum Then
bdatum = Application.Match(CLng(begindatum), .Columns(1), 0)
If IsNumeric(bdatum) Then .Cells(bdatum, 1).Name = "BEGIN" Else MsgBox "Begindatum niet gevonden in tabel."
End If
End With
With Sheets("Stroomverbruik")
einddatum = Application.InputBox("title", "title2", FormatDateTime(Date, vbShortDate), Type:=1)
If einddatum Then
edatum = Application.Match(CLng(einddatum), .Columns(1), 0)
If IsNumeric(bdatum) Then .Cells(edatum, 1).Name = "EIND" Else MsgBox "Einddatum niet gevonden in tabel."
End If
End With
ActiveWorkbook.Names.Add Name:="Grafiekstroom_data", RefersTo:="BEGIN:EIND"
End Sub
Als ik de code zoals hierboven gebruik, komt er in de naamsdefinitie "Begin" en "Eind" te staan i.p.v. celnummer.