ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet and workbook name question. (https://www.excelbanter.com/excel-programming/295586-re-worksheet-workbook-name-question.html)

Tom Ogilvy

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





All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com