Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Cells the way you have used it here is equivalent to calling ActiveSheet.Cells. Almost never should we be working with the active sheet because the user can change it on us while the code is executing. Avoid activate and selectAvoid activate and select by explicitly setting a variable to the range you want to work with.

Cells the way you have used it here is equivalent to calling ActiveSheet.Cells. Almost never should we be working with the active sheet because the user can change it on us while the code is executing. Avoid activate and select by explicitly setting a variable to the range you want to work with.

Cells the way you have used it here is equivalent to calling ActiveSheet.Cells. Almost never should we be working with the active sheet because the user can change it on us while the code is executing. Avoid activate and select by explicitly setting a variable to the range you want to work with.

added 283 characters in body
Source Link
RubberDuck
  • 30.9k
  • 6
  • 71
  • 174

Here is a really good example of an opportunity to extract a method. The comment is a dead give away (and a good start on a good name).

'set up which items to be read
For i = 1 To NumberOfTags
    ServerHandles(i) = MyOPCItems(i).ServerHandle
Next i

#Other things

#Other things

Here is a really good example of an opportunity to extract a method. The comment is a dead give away (and a good start on a good name).

'set up which items to be read
For i = 1 To NumberOfTags
    ServerHandles(i) = MyOPCItems(i).ServerHandle
Next i

#Other things

added 1595 characters in body
Source Link
RubberDuck
  • 30.9k
  • 6
  • 71
  • 174

#Other things

   'free the memory
   Erase Values()
   Erase Errors()

Exit Sub

It's nice that you're cleaning up after yourself, but I seriously don't understand why you're doing this. These arrays are locally scoped. Once they go out of scope the reference count will decrement to zero and the memory will be reclaimed.

#Other things

   'free the memory
   Erase Values()
   Erase Errors()

Exit Sub

It's nice that you're cleaning up after yourself, but I seriously don't understand why you're doing this. These arrays are locally scoped. Once they go out of scope the reference count will decrement to zero and the memory will be reclaimed.

added 1595 characters in body
Source Link
RubberDuck
  • 30.9k
  • 6
  • 71
  • 174
Loading
Source Link
RubberDuck
  • 30.9k
  • 6
  • 71
  • 174
Loading