Error 1004 on long For loop, adding hyperlinks. What's going on?

N

N L

Greetings.

I have a very large worksheet with about 110,000 rows, and a VBA
program that analyzes each of these rows, comparing their values with
other sheets in the same workbook.

In one Sub in my program, I have a For loop that I expect to execute
once per row (about 110,000 times). Its job is to add a hyperlink to a
cell if the values in the row have a certain value:

ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Cells(52206, 14),
Address:="", SubAddress:="TargetWorksheet!A1"


The problem is that I get a "Run-time error '1004': Application-
defined or object-defined error" on iteration #52205 (the counter in
the For loop reads 52205). I've previously only gotten this error when
I incorrectly referred to an object. Any idea why this is happening?

Could I be exceeding the acceptable range of a Hyperlink anchor?

Thanks,
N. Lee
 
N

N L

Greetings.

I have a very large worksheet with about 110,000 rows, and a VBA
program that analyzes each of these rows, comparing their values with
other sheets in the same workbook.

In one Sub in my program, I have a For loop that I expect to execute
once per row (about 110,000 times). Its job is to add a hyperlink to a
cell if the values in the row have a certain value:

ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Cells(52206, 14),
Address:="", SubAddress:="TargetWorksheet!A1"

The problem is that I get a "Run-time error '1004': Application-
defined or object-defined error" on iteration #52205 (the counter in
the For loop reads 52205). I've previously only gotten this error when
I incorrectly referred to an object. Any idea why this is happening?

Could I be exceeding the acceptable range of a Hyperlink anchor?

Thanks,
N. Lee

I've resolved the issue. Excel has a limit of 65,530 hyperlinks on a
single page. Instead of reporting this limit, VBA just gives a generic
error.
Shame on Excel on this shoddy behavior.

N. Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top