Worksheet Code Modules

Any code that has been place in a worksheet code module will default to referring to that specific worksheet.
The following will refer to the corresponding worksheet containing the code

Range() 
Cells()

How to refer to the specific worksheet name when inside a worksheet code module

Dim objWorksheet As Worksheet 
   objWorksheet = Application.Worksheets(Range("A1").Parent.Name)
   objWorksheet.Range("D4").Value = "some text"



General Code Modules

Any code placed in a General code module will default to the active worksheet.
The following two lines of code are equivalent when placed in a general code module.

Range() 
ActiveSheet.Range()



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext