Hi Toby
Yes, I have used a similar algorthm to convert letters to numbers. Just
seems a shame that a requirement so simple should require other code. If my
columns were contiguous then this would suffice:
Range(Columns(startCol), Columns(endCol)).AutoFit
.... but they need not be contiguous.
Seems like I need the sledgehammer after all <g>
Thanks
Geoff
"Toby Erkson" wrote:
> How about using a function to convert the number to a letter? For example,
> here's a function I used when working with the first 26 (A-Z) columns:
> -----
> Function ConvertValue2Column(iValue As Integer) As String
> 'Takes a number and converts it into a letter to be used for cell column
> calcs.
>
> Dim Result As String, ASCIIVal As Integer
>
> ASCIIVal = 64 'Asc("@")
> If (ASCIIVal + iValue) > 90 Then
> MsgBox "Table too long!", vbExclamation, "Error!"
> Exit Function
> End If
> Result = Chr(ASCIIVal + iValue)
> ConvertValue2Column = Result
> End Function
> -----
>
> So, using the above function:
> Range(Columns(ConvertValue2Column(startCol)),
> Columns(ConvertValue2Column(startCol) + 1),
> Columns(ConvertValue2Column(endCol))).AutoFit
>
>
>
> "Geoff" <(E-Mail Removed)> wrote in message
> news:BDF9C841-2BAB-413E-B964-(E-Mail Removed)...
> >I cannot work out how to refer to a group of columns by numbers.
> > this doesn't work or any varaition using Columns intead of Range:
> >
> > Dim startCol as Byte, endCol as Byte
> >
> > Range(Columns(startCol), Columns(startCol + 1), Columns(endCol)).AutoFit
> >
> > Listing each column separately works but how can I group them on 1 line?
> >
> > Columns(startCol).AutoFit
> > Columns(startCol +1).AutoFit
> > Columns(endCol).AutoFit
>
>
>
|