ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   codename and cell selection (https://www.excelbanter.com/excel-programming/388870-codename-cell-selection.html)

ll

codename and cell selection
 
Hi,
I am needing help in the use of sheet codename in VBA. Currently,
I've successfully assigned the sheet codename to a string variable and
have tested it with a msgbox. I get error messages when the code gets
'below' the msgbox line (into the cell selection area.
Does anyone know what the proper syntax is for selecting all cells in
a sheet (referring to the sheet with its codename, rather than its
worksheet (tab) name)?
Thanks for your help,
Louis
----------

'\\\\CodeNameString = LCase(wks.CodeName)
CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)

If CodeNameString = "Sheet1" Then
'\\\\LOldWb.Sheets(CodeNameString).Visible = True
'\\\\LOldWb.Sheets(CodeNameString).Select

LOldWb.Sheets(CodeNameString).Cells.Select


Jim Thomlinson

codename and cell selection
 
Since you have a sheet object use that...

'\\\\CodeNameString = LCase(wks.CodeName)
CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)

If CodeNameString = "Sheet1" Then
'\\\\LOldWb.Sheets(CodeNameString).Visible = True
'\\\\LOldWb.Sheets(CodeNameString).Select

LOldWb.Activate
wks.CodeName.Cells.Select

--
HTH...

Jim Thomlinson


"ll" wrote:

Hi,
I am needing help in the use of sheet codename in VBA. Currently,
I've successfully assigned the sheet codename to a string variable and
have tested it with a msgbox. I get error messages when the code gets
'below' the msgbox line (into the cell selection area.
Does anyone know what the proper syntax is for selecting all cells in
a sheet (referring to the sheet with its codename, rather than its
worksheet (tab) name)?
Thanks for your help,
Louis
----------

'\\\\CodeNameString = LCase(wks.CodeName)
CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)

If CodeNameString = "Sheet1" Then
'\\\\LOldWb.Sheets(CodeNameString).Visible = True
'\\\\LOldWb.Sheets(CodeNameString).Select

LOldWb.Sheets(CodeNameString).Cells.Select



ll

codename and cell selection
 
Thanks - I've altered my code to that below but I get the "Invalid
Qualifier" error.

-----

CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)


If CodeNameString = "Sheet1" Then

LOldWb.Activate
wks.CodeName.Cells.Select


Jim Thomlinson

codename and cell selection
 
Sorry... I put in an extra dot...

CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)


If CodeNameString = "Sheet1" Then

LOldWb.Activate
wksCodeName.Cells.Select
--
HTH...

Jim Thomlinson


"ll" wrote:

Thanks - I've altered my code to that below but I get the "Invalid
Qualifier" error.

-----

CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)


If CodeNameString = "Sheet1" Then

LOldWb.Activate
wks.CodeName.Cells.Select



ll

codename and cell selection
 
On May 7, 1:22 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Sorry... I put in an extra dot...

CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)

If CodeNameString = "Sheet1" Then

LOldWb.Activate

I wksCodeName.Cells.Select
--
HTH...

Jim Thomlinson

"ll" wrote:
Thanks - I've altered my code to that below but I get the "Invalid
Qualifier" error.


-----


CodeNameString = wks.CodeName


Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)


If CodeNameString = "Sheet1" Then


LOldWb.Activate
wks.CodeName.Cells.Select



Thanks
I've removed that extra dot, but now it is giving me an 'object
required' error message.


Bob Phillips

codename and cell selection
 
Maybe

wksCodeName.Cells.Select

should be

wks.Cells.Select


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"ll" wrote in message
oups.com...
On May 7, 1:22 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Sorry... I put in an extra dot...

CodeNameString = wks.CodeName

Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)

If CodeNameString = "Sheet1" Then

LOldWb.Activate

I wksCodeName.Cells.Select
--
HTH...

Jim Thomlinson

"ll" wrote:
Thanks - I've altered my code to that below but I get the "Invalid
Qualifier" error.


-----


CodeNameString = wks.CodeName


Response = MsgBox(CodeNameString, vbYesNoCancel + vbCritical +
vbDefaultButton2)
'Msg = CodeNameString
'MsgBox = (Msg)


If CodeNameString = "Sheet1" Then


LOldWb.Activate
wks.CodeName.Cells.Select



Thanks
I've removed that extra dot, but now it is giving me an 'object
required' error message.





All times are GMT +1. The time now is 01:36 AM.

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