简体   繁体   English

Excel VBA:如何更改上次使用的列中单元格的值?

[英]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." 我是VBA的新手,正在尝试查找上一次使用的列(每月更改),并将该列中的第二行单元格更改为“ Apple”。 The values in the last used column start from row 5, but I need to change row 2. Can anyone help? 最后使用的列中的值从第5行开始,但是我需要更改第2行。有人可以帮忙吗? 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel VBA - 如何将单元格引用更改为倒数第二列和最后一列 - Excel VBA - How to change a cell reference to the second last and last column VBA Excel ComboBox 值到范围(“特定单元格”到最后一列数据) - VBA Excel ComboBox value to Range ("specific cell" to last column with data) Excel VBA - 清除最后使用的单元格的内容 - Excel VBA - clear content to the last used cell 在 Excel VBA 中查找最后使用的单元格 - Find last used cell in Excel VBA 如何在Excel中使用VBA确定最后一列(具有值的最后一列)? - How to determine the last column(last column with value) using VBA in excel? Excel VBA:如何将公式转换为最后使用的列的值? - Excel VBA: How to turn formulas into values for the last used column? Excel Vba,如何用另一个单元格更改单元格值? - Excel Vba, How to change cell value with another cell? Excel VBA:如何将值粘贴到表的最后一行的第一个单元格中? - Excel VBA: How to paste a value in the first Cell of the last row of a table? 获取 Excel 中使用的最后一个单元格的值 - To get the value of last cell used in Excel 检查哪个是特定列中最后一个具有值的单元格,然后在excel vba中选择其下方的单元格 - Check which is the last cell in a specific column which has a value and select the cell below it in excel vba
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM