ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting aws to name stored in an array (https://www.excelbanter.com/excel-programming/378172-setting-aws-name-stored-array.html)

Barb Reinhardt

Setting aws to name stored in an array
 
I have the following:

For iCtr = LBound(myWSNames) To UBound(myWSNames)
Set aWS = Nothing
Set aWS = Sheets(myWSNames(iCtr))
if aws is not nothing then
'do something
end if
Next iCtr

I have a list of worksheet code names in mywsnames. I'd like to set the
aws to be the name in the mywsnames list. It's not working. What do I need
to change?

Thanks

JLGWhiz

Setting aws to name stored in an array
 
Maybe: If aWS Not Is Nothing Then
'Do something

"Barb Reinhardt" wrote:

I have the following:

For iCtr = LBound(myWSNames) To UBound(myWSNames)
Set aWS = Nothing
Set aWS = Sheets(myWSNames(iCtr))
if aws is not nothing then
'do something
end if
Next iCtr

I have a list of worksheet code names in mywsnames. I'd like to set the
aws to be the name in the mywsnames list. It's not working. What do I need
to change?

Thanks


JLGWhiz

Setting aws to name stored in an array
 
Had the syntax wrong: If Not aWS Is Nothing Then
'Do Something

Sorry bout that!

"Barb Reinhardt" wrote:

I have the following:

For iCtr = LBound(myWSNames) To UBound(myWSNames)
Set aWS = Nothing
Set aWS = Sheets(myWSNames(iCtr))
if aws is not nothing then
'do something
end if
Next iCtr

I have a list of worksheet code names in mywsnames. I'd like to set the
aws to be the name in the mywsnames list. It's not working. What do I need
to change?

Thanks



All times are GMT +1. The time now is 03:00 PM.

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