Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All
How can I select more than one column of a Worksheet object if I have the columns as numbers(long) and not characters? That is, in my example, simplified code I have: Dim lColStart As Long, lColEnd As Long lColStart = 1 lColEnd = 3 I want to select all columns from lColStart to lColEnd on the ActiveSheet. It seems that VB wants: ActiveSheet.Columns("A:C") but I want to use my longs only - I dont want to have to convert them to characters with a helper sub. I must be missing something - how can I use my longs to select the columns? Thanks in advance for any ideas. Chrisso |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This loops through all columns in the used range but you could easily set the start and end columns with variables or other fixed values. Sub marine() LastCol = ActiveSheet.UsedRange.Column(ActiveSheet.UsedRange .Columns.Count).Column Stop For c = 1 To LastCol Columns(c).Select 'do something Next c End Sub Mike "Chrisso" wrote: Hi All How can I select more than one column of a Worksheet object if I have the columns as numbers(long) and not characters? That is, in my example, simplified code I have: Dim lColStart As Long, lColEnd As Long lColStart = 1 lColEnd = 3 I want to select all columns from lColStart to lColEnd on the ActiveSheet. It seems that VB wants: ActiveSheet.Columns("A:C") but I want to use my longs only - I dont want to have to convert them to characters with a helper sub. I must be missing something - how can I use my longs to select the columns? Thanks in advance for any ideas. Chrisso |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again,
One way - ActiveSheet.Columns(3).Resize(, 3) Regards, Peter T "Chrisso" wrote in message ups.com... Hi All How can I select more than one column of a Worksheet object if I have the columns as numbers(long) and not characters? That is, in my example, simplified code I have: Dim lColStart As Long, lColEnd As Long lColStart = 1 lColEnd = 3 I want to select all columns from lColStart to lColEnd on the ActiveSheet. It seems that VB wants: ActiveSheet.Columns("A:C") but I want to use my longs only - I dont want to have to convert them to characters with a helper sub. I must be missing something - how can I use my longs to select the columns? Thanks in advance for any ideas. Chrisso |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Mike & Peter for your code examples.
Can I conclude then that it is not possible to do something nice and simple like: ActiveSheet.Columns("1:3").Select ??? I will use the .Resize property(?) but VB does not make it very readable! Chrisso |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can I conclude then that it is not possible to do something nice and
simple like: ActiveSheet.Columns("1:3").Select Corrrect I will use the .Resize property(?) but VB does not make it very readable! What's unreadable about - ActiveSheet.Columns(firstCol).Resize(,qtyCols) or ..Resize(,lastCol-firstCol+1) Regards, Peter T "Chrisso" wrote in message oups.com... Thanks Mike & Peter for your code examples. Can I conclude then that it is not possible to do something nice and simple like: ActiveSheet.Columns("1:3").Select ??? I will use the .Resize property(?) but VB does not make it very readable! Chrisso |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Columns now numbers rather than letters how do i get letters back | Excel Discussion (Misc queries) | |||
columns appear as numbers not letters | Excel Discussion (Misc queries) | |||
I have numbers instead of letters on my columns, why? | Excel Discussion (Misc queries) | |||
Help, my columns now have numbers instead of letters. | Excel Discussion (Misc queries) | |||
Columns in letters vs numbers | Excel Discussion (Misc queries) |