View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Worksheet and workbook name question.

ans = Msgbox "Is the sheet we need to work with active? If not, " &
_ vbNewline & "then answer no, select the sheet and rerun the macro"

if ans = vbNo then exit sub

With Activesheet




End With


or

before distributing the sheet

activesheet.Range("IV1").Numberformat = """the sheet"""


to check

for each sh in thisworkbook.worksheets
if Instr(1,sh.Range("IV1").Numberformat, "the sheet", vbTextCompare) then
set thSheet = sh
exit for
end if
Next


or create a defined name that refers to the sheet (and make it hidden)

range("Secret").Parent.Name

--
Regards,
Tom Ogilvy



"Mark" wrote in message
...
What is the proper way to refer to a workbook and/or a worksheet within

VBA such that the code remains unaffected if the user changes either the
object name or the sheet's tab position?

Thanks

Mark