Meaning of .Cells(.Rows.Count,“A”).End(xlUp).row

前端 未结 4 1764
日久生厌
日久生厌 2020-12-04 11:12

I was just wondering if you could help me better understand what .Cells(.Rows.Count,\"A\").End(xlUp).row does. I understand the portion before the .End

4条回答
  •  醉梦人生
    2020-12-04 11:55

    The first part:

    .Cells(.Rows.Count,"A")
    

    Sends you to the bottom row of column A, which you knew already.

    The End function starts at a cell and then, depending on the direction you tell it, goes that direction until it reaches the edge of a group of cells that have text. Meaning, if you have text in cells C4:E4 and you type:

    Sheet1.Cells(4,"C").End(xlToRight).Select
    

    The program will select E4, the rightmost cell with text in it.

    In your case, the code is spitting out the row of the very last cell with text in it in column A. Does that help?

提交回复
热议问题