I have a VBA code in Excel with an issue. I ask the user to give a number (which is actually a week's number). This data is going to set for range Q1. I have converted the dates (which are already in the sheet) to the column "K" to the weeks number with the formula "Weeknum". Now I want to keep only those rows which are equal with the user's entry that is shown in the cell "Q1".
Now the result is that the sheet shows the weeknum only as values not as formulas, but nothing has been deleted.
range("K6").FormulaR1C1 = "=WEEKNUM(RC[-10])"
range("K6").Select
Selection.AutoFill Destination:=range("K6:K65536")
range("K6:K65536").Copy
range("K6:K65536").PasteSpecial xlPasteValues
Dim Valid3 As Boolean
Dim Data3 As String
While Valid3 = False
het = InputBox("Kérlek, add meg melyik hétre szűrjek rá!", "További szűrés beállítása", "")
If IsNumeric(het) Then
Valid3 = True
range("Q1").Value = het
Else
Valid3 = False
MsgBox "HIBA! Valószínűleg rossz formátumban adtad meg a szűrendő hetet."
End If
Wend
Dim Rng3 As range
Dim x3 As Long
Set Rng3 = range("K6:K" & range("K65536").End(xlUp).Row)
For x3 = Rng3.Rows.Count To 1 Step -1
If InStr(1, Rng3.Cells(x3, 1).Value, range("Q1")) = 0 Then
Rng3.Cells(x3, 1).EntireRow.Delete
End If
Next x3