![](/img/trans.png)
[英]Excel VBA to input formula followed by text into cell or cell formula
[英]Read cell and use text as input for VBA formula
我一直在尋找很長一段時間來為我的問題找到一個簡單的解決方案,但我找不到它。 我的問題是我想引用一個單元格並將其用作我的VBA代碼中的文本。
例如:說單元格= C104
VBA會做:
wb2.Sheets("Cell").Range("F8:F22").Copy
wb1.Sheets("asd").Range("B7:B21").PasteSpecial
這不起作用,因為它實際上並沒有使用單元格中的文本。 我嘗試過使用cell().Text
和.value
但它們不起作用。
您有多個工作簿和多個可用的工作表,可能是單元的父級。 您需要最終引用單元格,並將其.Value
或.Text
用作工作表名稱,而不依賴於Activesheet作為默認父級。
dim myWS as string
myWS = wb1.Sheets("asd").Range("C104").value '◄ this gets the value of cell. I don't know if I have referenced the correct workbook and worksheet
wb2.Sheets(myWS).Range("F8:F22").Copy _
destination:=wb1.Sheets("asd").Range("B7")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.