Hi,
I’m using the next VLOOKUP function at excel and itworks fine à =VLOOKUP($B2,SHEET20!$1:$1048576,1,0) (im running it from different sheet (sheet1).
My problem is that when I’m record Macro with VLOOKUP formula it’s notworking.
I understood that I need to make some changes to fit VLOOKUP functionto “VBA” VLOOKUP but I failed to do it.
Any idea how can I edit this VLOOKUP to “VBA VLOOKUP”?
My code with my last try:
ActiveSheet.ListObjects("MyData").Range.AutoFilter Field:=2,Criteria1:= _
"<>"
Columns("A:B").Select
Selection.Copy
Sheets.AddAfter:=ActiveSheet
ActiveSheet.Paste
StartDate =DateAdd("d", "-7", Date)
EndDate = Now
Range("A1:b1").AutoFilter Field:=2, _
Criteria1:=">=" & StartDate, _
Operator:=xlAnd, _
Criteria2:="<=" & EndDate
Columns("A:B").Select
Selection.Copy
Range("C1").Select
ActiveSheet.Paste
Columns("A:B").Select
Application.CutCopyMode =False
Selection.DeleteShift:=xlToLeft
Sheets("Sheet1").Select
ActiveWorkbook.SlicerCaches("Slicer_Time_filter").ClearManualFilter
ActiveWindow.ScrollColumn =2
ActiveWindow.ScrollColumn =3
ActiveWindow.ScrollColumn =4
ActiveWindow.ScrollColumn =5
ActiveWindow.ScrollColumn =6
Range("M1").Select
ActiveCell.FormulaR1C1 ="Plat"
Range("M2").Select
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
.Range("M2").Formula ="=VLOOKUP(B2,Sheet21!$A:$B,1,0)"
End With
Range("M2").Select
Selection.FillDown
End Sub
Thanks!!!
I’m using the next VLOOKUP function at excel and itworks fine à =VLOOKUP($B2,SHEET20!$1:$1048576,1,0) (im running it from different sheet (sheet1).
My problem is that when I’m record Macro with VLOOKUP formula it’s notworking.
I understood that I need to make some changes to fit VLOOKUP functionto “VBA” VLOOKUP but I failed to do it.
Any idea how can I edit this VLOOKUP to “VBA VLOOKUP”?
My code with my last try:
- I want torun VLOOKUP function on cell M2 at sheet1
Sub aaa()
ActiveSheet.ListObjects("MyData").Range.AutoFilter Field:=2,Criteria1:= _
"<>"
Columns("A:B").Select
Selection.Copy
Sheets.AddAfter:=ActiveSheet
ActiveSheet.Paste
StartDate =DateAdd("d", "-7", Date)
EndDate = Now
Range("A1:b1").AutoFilter Field:=2, _
Criteria1:=">=" & StartDate, _
Operator:=xlAnd, _
Criteria2:="<=" & EndDate
Columns("A:B").Select
Selection.Copy
Range("C1").Select
ActiveSheet.Paste
Columns("A:B").Select
Application.CutCopyMode =False
Selection.DeleteShift:=xlToLeft
Sheets("Sheet1").Select
ActiveWorkbook.SlicerCaches("Slicer_Time_filter").ClearManualFilter
ActiveWindow.ScrollColumn =2
ActiveWindow.ScrollColumn =3
ActiveWindow.ScrollColumn =4
ActiveWindow.ScrollColumn =5
ActiveWindow.ScrollColumn =6
Range("M1").Select
ActiveCell.FormulaR1C1 ="Plat"
Range("M2").Select
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
.Range("M2").Formula ="=VLOOKUP(B2,Sheet21!$A:$B,1,0)"
End With
Range("M2").Select
Selection.FillDown
End Sub
Thanks!!!