Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Selecting columns with column numbers not letters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Selecting columns with column numbers not letters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Selecting columns with column numbers not letters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Selecting columns with column numbers not letters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Selecting columns with column numbers not letters

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
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
Columns now numbers rather than letters how do i get letters back SalExcel10 Excel Discussion (Misc queries) 2 March 4th 10 02:48 PM
columns appear as numbers not letters Clairey Excel Discussion (Misc queries) 2 June 30th 06 11:15 AM
I have numbers instead of letters on my columns, why? lisawjs Excel Discussion (Misc queries) 3 October 20th 05 07:18 PM
Help, my columns now have numbers instead of letters. caliskier Excel Discussion (Misc queries) 2 August 11th 05 02:55 PM
Columns in letters vs numbers garyflood Excel Discussion (Misc queries) 1 April 22nd 05 03:21 PM


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