Getrangebyname

Hi Laurence,

I have a question with getRangeByName when I was developing a report for our customers. How to find the cell if more than 1 worksheet have the same cell name.

For example;

one workbook has 2 worksheet, and both worksheet have “test” as cell A1’s name. How do I find this A1 cell corresponding to <span style=“font-size: 10pt; font-family: “MS Sans Serif”;”>particular worksheet?

I tried my example
excel.Worksheets.GetRangeByName(“test”)(0, 0).PutValue(“me1”)
excel.Save(“C:\test.xls”)
System.Diagnostics.Process.Start(“c:\test.xls”)

The second worksheet has “me1” at A1, and the first worksheet has “gHgtbburp”

Could you please upload your file here?

MS Excel cannot set one name to two ranges. So I think cell A1’s name in your first worksheet is “Sheet1!test” and the second is “test”. You can verify it by “Insert->Name->Define”.

So please try:

excel.Worksheets.GetRangeByName(“Sheet1!test”)(0, 0).PutValue(“me1”)

excel.Worksheets.GetRangeByName(“test”)(0, 0).PutValue(“me1”)
excel.Save(“C:\test.xls”)
System.Diagnostics.Process.Start(“c:\test.xls”)


By the way, “gHgtbburp” is a license warning. Please check

for reference.
You can put some value at Cell H20 to move the random string out of cell A1.