Additionally, instead of the formula looking up the channel by name each time, create a channel object after looking it up once and pass the object to the Calculation: Try setting external variables outside the Calculation, such as R1 and R2, then use those variable names in the text of the formula natively. Here are my thoughts on your existing code:
I can think of several ways to improve the execution and debugging of your existing code, but you make a good point about the ChnEvent.() possibly being the better option.
I don't see anything wrong with the code you provide, though of course I don't know what values you have stored in variables "L" and "s" at the moment that the execution turns ugly.
This script is running a series of calculations - on the order of several hundred similar to what is copied below. The bad news is I'm still getting the Access Violation Error, this time in a different part of the script. The channels aren't ordered as I had them in the text file, but it was getting to be such a large list people would just search for the channel they need anyway. The good news is I've put in that routine as suggested below and it seems to work well. Set DeleteChannels = Data.GetChannels(" *") Set Channel = Group.Channels(" RPM") : Channel.Name = Mid(Channel.Name, 12) Set Channel = Group.Channels(1) : Channel.Name = Mid(Channel.Name, 12) How about if instead you add a prefix to all the loaded channel names, such as " ", then when you find a particular channel in the external ASCII file you remove that prefix from the channel name, then when you're done reading the ASCII file request all the remaining " " channels and delete them, leaving just the channels you want, uncopied.
I'm not convinced that copying 400 or so channels you want to keep is the best way to go, though that's an ugly error that I wish wasn't happening to you.