简体   繁体   English

在Excel中动态选择列范围

[英]selecting Range of a column dynamically in Excel

I want the name of the workbook to be filled in column A up to the last row where data exist in the worksheet , the code I am using to find the last row where data exist is 我希望工作簿的名称在A列中填充到工作表中数据存在的最后一行,我用来查找数据存在的最后一行的代码是

lastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count

and the code store name upto column A10 is 并且直到A10列的代码存储名称是

Sub testValue()

strAddress2 = "A3:A10"

wbName = ThisWorkbook.Name

Range(strAddress2).Value = Left(wbName, InStrRev(wbName, ".") - 1)

End Sub

I want to select the range dynamically with the value stored in variable "lastRow" but not sure how to do that 我想使用存储在变量“ lastRow”中的值动态选择范围,但不确定如何执行该操作

strAddress2 = "A3:A" & lastRow

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

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