Reputation: 21
Good day, I set some IDS to some cells in Excel using this:
ActiveCell.id = "whateverID"
I don't know if those IDs are saved, and now I need to get the Values of those Cells but by ID, I don't have any idea on how to get it done, I need it because I want to get the values of specific cells using their IDs if such cells change their position, hope you understand.
Or if you know a better way to get it done the better.
Upvotes: 1
Views: 5082
Reputation: 149335
I need it because I want to get the values of specific celss using their IDs if such cells change their position, hope you understand.
For that don't use ID's. Name the cell. For example
ThisWorkbook.Sheets("Sheet1").Range("A1").Name = "whateverID"
Now even if that range moves, you can always use the following to write/read that cell
WRITE
ThisWorkbook.Sheets("Sheet1").Range("whateverID").Value = "Something"
OR
READ
Debug.Print ThisWorkbook.Sheets("Sheet1").Range("whateverID").Value
You might also want to read more about Define named cell references or ranges
Upvotes: 1