On May 22, 11:25 am, Andreas Leitgeb <
a...@gamma.logic.tuwien.ac.at>
wrote:
> sd <
sham...@hotmail.com> wrote:
> > Now I'm trying to find out how to selecte multiple ranges all at once
> > while referencing cols innumbers. Similar to:
> > set valuesRange [$worksheet Range "A10:A20,C10:E20"]
> > I tried:
> > set range [$cells Range [$cells Item 10 1] [$cells Item 20 1]],[$cells
> > Range [$cells Item 10 3] [$cells Item 20 5]]
> > But it didn't work
>
> I don't know much about tcom andexcel, but if your problem is
> converting a numericcolumnspecification to a letter string,
> then I guess, it should not be all that hard toconvertit in
> your script before calling [$worksheet Range ...]
>
> proc colname {num} {
> # for 1 to 26 return A to Z
> # for 27 to 702 return AA to ZZ
> # for 703 to ...
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -
I was hoping there would be a straight forward way of doing that, but
writing a small proc is always an option:
proc colN {n} {
if {$n<=26} {puts [format %c [expr {$n+64}]]
} else {
set a [expr {$n/26}] ;# rounded down
set b [expr {$n%$a}] ;# remainder of division
set c [expr {$n - $a*26}]
if {$c==0} {set c 26}
puts [format %c [expr {$a+64}]][format %c [expr {$c+64}]]
}
}