While you can use RANGE in the form of RANGE("A1"), the RANGE is more often use to define a start and end point ie.
RANGE("A1","A20"). If you are assigning a single value to a cell you may want to look at a CELLS. CELLS will define it reference location using Row number and Column number ie
CELLS(15,"D") would reference D15. You can combine CELLS with to define the start and end point of your range numerically using:
which would be the equivalent of A1:A20
In your code replace
Range("A" & X).Value = str with
CELLS(1,X).Value = str