![]() |
How to get sheet from sheet name
Hi everyone
I am using Sheet3.Cells(1, 1) to get some value from Sheet3 but Sheet3 can change if i insert new sheets . So is there any function that retruns worksheet if i provides the sheet name. so instead of using varaible = Sheet3.Cells(attRow, attCol) i can use Dim sheet , varaible sheet = unknowFunciton("data sheet") ' "data sheet" is the name of Sheet3 varaible = sheet.Cells(1, 1) Regards Amaninder Saini :) |
How to get sheet from sheet name
Generally people use the codename because it does not change.
" wrote: Hi everyone I am using Sheet3.Cells(1, 1) to get some value from Sheet3 but Sheet3 can change if i insert new sheets . So is there any function that retruns worksheet if i provides the sheet name. so instead of using varaible = Sheet3.Cells(attRow, attCol) i can use Dim sheet , varaible sheet = unknowFunciton("data sheet") ' "data sheet" is the name of Sheet3 varaible = sheet.Cells(1, 1) Regards Amaninder Saini :) |
How to get sheet from sheet name
If you use Sheet3.Cells(1, 1) that means that you are using the codename
(the VBA name if you like), not the Excel name. As such it will not change just by inserting new sheets, only if you change it in the VBIDE or by code. You could always set a sheet variable Dim sh As Worksheet Set sh = Worksheets("Sheet3") and then refer to sh later on. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) wrote in message ps.com... Hi everyone I am using Sheet3.Cells(1, 1) to get some value from Sheet3 but Sheet3 can change if i insert new sheets . So is there any function that retruns worksheet if i provides the sheet name. so instead of using varaible = Sheet3.Cells(attRow, attCol) i can use Dim sheet , varaible sheet = unknowFunciton("data sheet") ' "data sheet" is the name of Sheet3 varaible = sheet.Cells(1, 1) Regards Amaninder Saini :) |
How to get sheet from sheet name
hi man, Is this your mean. SUB GETNAME() FOR EACH SH IN ACTIVEWORKBOOK.WORKSHEETS SH.NAME = SH.RANGE(\"A1\").VALUE NEXT SH END SUB -- vumian ------------------------------------------------------------------------ vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494 View this thread: http://www.excelforum.com/showthread...hreadid=567427 |
All times are GMT +1. The time now is 07:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com