Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Convert String to a Contstant

to avoid being tied to a XML layout I identified each column as a Constant

Global Const CTrack1BD1 = "A"
Global Const CTrack1BD2 = "B"
Global Const CTrack2BD1 = "C"
Global Const CTrack2BD2 = "D"

and in my code I simply use eg range(CTrack1BD1 & counter) = ....

However now I want to use another cell value to slect the right Column
so cell "contains string "XXX2BD1"

My ideas was to use
TrackColumn = "CTrack" & right("XXX2BD1",4)
followed by
range("z1") = range( TrackColumn & a)

however the TrackColumn remains a sting and is not "replaced" by the Const
value "C"

any pointer would be much appriciated

Ron B
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Convert String to a Contstant

Maybe something like this

Sub ABC()
Dim mycol As Collection
Dim a As Long
Dim rng As Range
Set mycol = New Collection
mycol.Add "A", "CTrack1BD1"
mycol.Add "B", "CTrack1BD2"
mycol.Add "C", "CTrack2BD1"
mycol.Add "D", "CTrack2BD2"

trackcolumn = "CTrack" & Right("XXX2BD1", 4)
a = 5
Set rng = Range(mycol.Item(trackcolumn) & a)
MsgBox rng.Address

End Sub


--
Regards,
Tom Ogilvy



"Ron B" wrote in message
...
to avoid being tied to a XML layout I identified each column as a Constant

Global Const CTrack1BD1 = "A"
Global Const CTrack1BD2 = "B"
Global Const CTrack2BD1 = "C"
Global Const CTrack2BD2 = "D"

and in my code I simply use eg range(CTrack1BD1 & counter) = ....

However now I want to use another cell value to slect the right Column
so cell "contains string "XXX2BD1"

My ideas was to use
TrackColumn = "CTrack" & right("XXX2BD1",4)
followed by
range("z1") = range( TrackColumn & a)

however the TrackColumn remains a sting and is not "replaced" by the Const
value "C"

any pointer would be much appriciated

Ron B



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Convert String to a Contstant

Thanks Tom, indeed this would work....but
I think it will put to much overhead on my macro as I have to "enrich" a few
hundred events each min.

So I will stick to my workaround by calculating the column

help is appriciated though

"Tom Ogilvy" wrote:

Maybe something like this

Sub ABC()
Dim mycol As Collection
Dim a As Long
Dim rng As Range
Set mycol = New Collection
mycol.Add "A", "CTrack1BD1"
mycol.Add "B", "CTrack1BD2"
mycol.Add "C", "CTrack2BD1"
mycol.Add "D", "CTrack2BD2"

trackcolumn = "CTrack" & Right("XXX2BD1", 4)
a = 5
Set rng = Range(mycol.Item(trackcolumn) & a)
MsgBox rng.Address

End Sub


--
Regards,
Tom Ogilvy



"Ron B" wrote in message
...
to avoid being tied to a XML layout I identified each column as a Constant

Global Const CTrack1BD1 = "A"
Global Const CTrack1BD2 = "B"
Global Const CTrack2BD1 = "C"
Global Const CTrack2BD2 = "D"

and in my code I simply use eg range(CTrack1BD1 & counter) = ....

However now I want to use another cell value to slect the right Column
so cell "contains string "XXX2BD1"

My ideas was to use
TrackColumn = "CTrack" & right("XXX2BD1",4)
followed by
range("z1") = range( TrackColumn & a)

however the TrackColumn remains a sting and is not "replaced" by the Const
value "C"

any pointer would be much appriciated

Ron B




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
Convert to string help pokdbz Excel Discussion (Misc queries) 1 June 10th 08 04:59 PM
convert a string to range? JK Excel Worksheet Functions 4 June 20th 06 01:04 AM
Convert Date to STring tonymaguire Excel Discussion (Misc queries) 9 February 15th 06 11:33 AM
How to convert string to a date galsaba Excel Worksheet Functions 3 March 4th 05 05:20 PM
Convert Date to String Michael168[_31_] Excel Programming 1 October 7th 03 10:44 AM


All times are GMT +1. The time now is 06:48 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"