简体   繁体   中英

Reference a Cell value from another Cell (VBA)

I have a Worksheet (MasterData) that contains the value "J" in cell B1. In cell C1, I have the value "10". With that information, I want to access another worksheets and get the value from cell J10. However I can't do something like:

myValue = Sheets("MySheet").Cells(Sheets("MasterData").Cells("B1").Value & Sheets("MasterData").Cells("C1").Value)

Any help would be appreciated. Thanks.

Try

myValue = Sheets("MySheet").Range( _
       Sheets("MasterData").Range("B1").Value _
     & Sheets("MasterData").Range("C1").Value _
).Value

尝试
myValue = Sheets("AnotherSheet").Range(Sheets("MySheet").Cells(Sheets("MasterData").Cells("B1").Value & Sheets("MasterData").Cells("C1").Value))

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