0
ActiveCell.FormulaR1C1 = "Y"
Range("B1").Select

Dim lastcellex As String

Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select

lastcellex = ActiveCell.Address
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:lastcellex")

Can anyone help me as to why I keep getting this error? I set the variable to be equal to the last cell on the range but one column over. So if the range in column A was A55, lastcellex would be B55. I am trying to make it autofill from B1:B55.

Please let me know what you guys think.

1
  • 1
    One line: Range("B1").AutoFill Destination:=Range("B1:B" & Range("A1").End(xlDown).Row+1) Commented Aug 15, 2017 at 17:41

1 Answer 1

1

It should be:

Selection.AutoFill Destination:=Range("B1:" & lastcellex)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.