简体   繁体   中英

Excel VBA: How to change value of cell in last used column?

I am new to VBA and am trying to locate the last used column (changes monthly) and change the second row cell in that column to "Apple." The values in the last used column start from row 5, but I need to change row 2. Can anyone help? This the code I have come up with, I understand it's flawed:

    Sub NameCell()
.Cells(5, Columns.Count).End(xlToLeft).Column.Select
.FormulaR3C1 = "Apple"
End Sub
Sub NameCell()
With ActiveSheet    
    .Cells(2,.Cells(5, .Columns.Count).End(xlToLeft).Column).Value = "Apple"
End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM