PC Review


Reply
Thread Tools Rate Thread

Convert String to a Contstant

 
 
=?Utf-8?B?Um9uIEI=?=
Guest
Posts: n/a
 
      5th Nov 2006
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 With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      5th Nov 2006
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" <(E-Mail Removed)> wrote in message
news:8590C8B5-702C-4608-BAFC-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?Um9uIEI=?=
Guest
Posts: n/a
 
      5th Nov 2006
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" <(E-Mail Removed)> wrote in message
> news:8590C8B5-702C-4608-BAFC-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Contstant Credential Prompt - SBS 2008 Standard, Win 7, Outlook 07 Paul Pincente Microsoft Outlook Discussion 3 26th Feb 2010 04:29 PM
Convert 'System.Collections.ObjectModel.ReadOnlyCollection(Of String)' to '1-dimensional array of String'. roidy Microsoft VB .NET 12 17th Jul 2009 10:53 AM
Convert Dictionary<string,SomeType> keys to List<string> buzzweetman@gmail.com Microsoft C# .NET 6 9th Aug 2006 03:54 PM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= Microsoft ASP .NET 2 26th Oct 2004 03:43 PM
Convert a string to Ascii codes and then back to string again Kai Bohli Microsoft C# .NET 11 8th Jul 2004 03:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:16 AM.