#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default arrays

Hi
I'd like to convert this case statement into an array

select Case PropName
Case "Name"
ColNum = 1
Case "Address1"
ColNum = 2
'more case statements
end select

instead
PropNames = Array("Name", "Address1"....)

colnum = <position of PropName in PropNames

I used to know this - i am blanking out.

Thanks for the help

Regards
Habib


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default arrays

Something like?

Propnames = Array("Name", "Address1")
PropName = "Address1"
colnum = Application.Match(PropName, Propnames, 0)

HTH

"HSalim[MVP]" wrote:

Hi
I'd like to convert this case statement into an array

select Case PropName
Case "Name"
ColNum = 1
Case "Address1"
ColNum = 2
'more case statements
end select

instead
PropNames = Array("Name", "Address1"....)

colnum = <position of PropName in PropNames

I used to know this - i am blanking out.

Thanks for the help

Regards
Habib



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default arrays

dim res as variant
dim PropNames as variant
dim PropName as string 'variant???
dim ColNum as long

propnames = array("name","address1", "something","addressx")

propname = "something"

res = application.match(propname,propnames,0)
if iserror(res) then
msgbox "not found!"
'what else should be done?
else
colNum = res
end if




"HSalim[MVP]" wrote:

Hi
I'd like to convert this case statement into an array

select Case PropName
Case "Name"
ColNum = 1
Case "Address1"
ColNum = 2
'more case statements
end select

instead
PropNames = Array("Name", "Address1"....)

colnum = <position of PropName in PropNames

I used to know this - i am blanking out.

Thanks for the help

Regards
Habib


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default arrays

DAve and Toppers,
Thanks for the immediate reply.
That hit the spot. aaah!
Regards
Habib

"Dave Peterson" wrote in message
...
dim res as variant
dim PropNames as variant
dim PropName as string 'variant???
dim ColNum as long

propnames = array("name","address1", "something","addressx")

propname = "something"

res = application.match(propname,propnames,0)
if iserror(res) then
msgbox "not found!"
'what else should be done?
else
colNum = res
end if




"HSalim[MVP]" wrote:

Hi
I'd like to convert this case statement into an array

select Case PropName
Case "Name"
ColNum = 1
Case "Address1"
ColNum = 2
'more case statements
end select

instead
PropNames = Array("Name", "Address1"....)

colnum = <position of PropName in PropNames

I used to know this - i am blanking out.

Thanks for the help

Regards
Habib


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of arrays DKS Excel Worksheet Functions 1 November 30th 06 08:38 PM
Arrays Tobro88 Excel Discussion (Misc queries) 3 November 18th 05 11:28 PM
Arrays Dani Excel Programming 1 June 7th 05 05:28 PM
Arrays JAmes L Excel Programming 3 April 21st 04 11:00 AM
Arrays Aaron Cooper Excel Programming 2 April 14th 04 07:42 PM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"