I recorded the below macro:
Sub Macro2()
'
' Macro1 Macro
'
'
Range("D108").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],R[-12]C[-1]:R[-4]C[1],2,FALSE)"
Range("E108").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],R[-12]C[-2]:R[-4]C,3,FALSE)"
Range("D108").Select
Selection.AutoFill Destination:=Range("D108:D110"), Type:=xlFillDefault
Range("D108:D110").Select
Range("E108").Select
Selection.AutoFill Destination:=Range("E108:E110"), Type:=xlFillDefault
Range("E108:E110").Select
End Sub
Then, I tried to modify, so I enter two single numbers as below:
Sub Macro1()
'
' Macro1 Macro
'
Dim row2start As Integer
row2start = InputBox("Write row to start this agenda", " ", "Enter your input text HERE")
Dim des2 As String
des2 = "D" & row2start + 1
Dim des3 As String
des3 = "E" & row2start + 1
Dim newActions As Integer
newActions = InputBox("count how many pending actions", " ", "Enter your input text HERE")
newActions2 = (row2start + 1) + newActions
Dim des4 As String
des4 = des2 & ":D" & newActions2
Dim des5 As String
des5 = des3 & ":E" & newActions2
Range(des2).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],R[-12]C[-1]:R[-4]C[1],2,FALSE)"
Range(des3).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],R[-12]C[-2]:R[-4]C,3,FALSE)"
Range(des2).Select
Selection.AutoFill Destination:=Range(des4), Type:=xlFillDefault
Range(des4).Select
Range(des3).Select
Selection.AutoFill Destination:=Range(des5), Type:=xlFillDefault
Range(des5).Select
End Sub
My problem is that I run it and nothing happens. I don't know why? Any ideas why? Technically, it is the same recorded macro, I just updated it with variables. I have double checked the variables but I cannot find any errors. Thanks a lot