VLOOKUP ohne Werte
10.02.2017 08:25:39
Sabrina
ich verzweifle an meinem Code.
Es läuft alles wunderbar durch, nur bekomme ich in der gewünschten Zelle kein Ergebnis ausgegeben.
Woran liegt es?
Hier mein Code:
Sub Trend()
Set Hier = ThisWorkbook.Worksheets("Auswertung")
'Überschriften einfügen
Dim lngSpalte As Long
lngSpalte = ActiveSheet.Range("XFD5").End(xlToLeft).Column
Dim Tag As String
Dim Monat As String
Dim Jahr As String
Tag = InputBox("Bitte Tag (TT) angeben")
Monat = InputBox("Bitte Monat (MM) angeben")
Jahr = InputBox("Bitte Jahr (JJJJ) angeben")
Cells(5, lngSpalte + 1).Value = Tag & "." & Monat & "." & Jahr
Cells(5, lngSpalte + 2).Value = "Trend"
Range(Cells(5, lngSpalte + 1), Cells(5, lngSpalte + 2)).Interior.ColorIndex = 15
Range(Cells(5, lngSpalte + 1), Cells(5, lngSpalte + 2)).Font.Bold = True
'Datei öffnen
Dim Dateiname, Pfad
Dim Datum As String
Datum = Jahr & Monat & Tag
Pfad = "X:\Data\"
Dateiname = Pfad & Datum & "-DRACO-RANKINGS-SM" & ".xlsx"
Workbooks.Open (Dateiname)
Da = ActiveWorkbook.Name
'Datei sortieren
Rows("1:1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Worksheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Worksheet1").AutoFilter.Sort.SortFields.Add Key:= _
Range("C1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Worksheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'sverweisen
Hier.Activate
ActiveSheet.Cells(6, lngSpalte + 1).Select
Cells(6, lngSpalte + 1).Formula = Application.VLookup(Hier.Cells(6, 1).Value, Workbooks(Da). _
Sheets("Worksheet1").Range("A1:D5000"), 3, False)
Selection.AutoFill Destination:=Range(Cells(6, lngSpalte + 1), Cells(255, lngSpalte + 1))
End Sub