Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Excel VBA - loop columns named AA, AB..etc

Hello
I have a problem, I am looping through this sequence of columns, see below, in order to change my list into a list more suited for pivottables; everything worked fine until now, when i also have columns AA,AB... until AO. If I just write them after column z (the z in the string) it will take three A:s then a B then A then C etc.... How can I fix this

(...
For i = 3 To 2
ThisCol = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i, 1
(...)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Excel VBA - loop columns named AA, AB..etc

Tobias,

Can't you just use the columns object.

For nIndex = 1 to 35
msgbox activesheet.columns(nIndex).address
next nIndex

you can do a lot more this way...

msgbox ActiveSheet.Columns(1).cells(1,1).address
msgbox ActiveSheet.Columns(1).cells(1,1).Resize(10,1).add ress

Robin Hammond
www.enhanceddatasystems.com

"Tobias" wrote in message
...
Hello,
I have a problem, I am looping through this sequence of columns, see

below, in order to change my list into a list more suited for pivottables;
everything worked fine until now, when i also have columns AA,AB... until
AO. If I just write them after column z (the z in the string) it will take
three A:s then a B then A then C etc.... How can I fix this?

(...)
For i = 3 To 26
ThisCol = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i, 1)
(...)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA - loop columns named AA, AB..etc

To keep it simple, why not just add another loop


For i = 1 To 15
ThisCol = "A" & Mid("ABCDEFGHIJKLMNO", i, 1)
(...)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tobias" wrote in message
...
Hello,
I have a problem, I am looping through this sequence of columns, see

below, in order to change my list into a list more suited for pivottables;
everything worked fine until now, when i also have columns AA,AB... until
AO. If I just write them after column z (the z in the string) it will take
three A:s then a B then A then C etc.... How can I fix this?

(...)
For i = 3 To 26
ThisCol = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", i, 1)
(...)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default SV: Excel VBA - loop columns named AA, AB..etc

Thank you Bob and Robin

Now it works.
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
Trying to use Lookup with Named Columns San Excel Worksheet Functions 1 January 23rd 07 09:35 AM
How can I sum data on a row from certain named columns? Liliana Excel Worksheet Functions 1 May 11th 06 08:07 PM
loop over columns kizzie Excel Discussion (Misc queries) 4 August 10th 05 01:31 PM
Loop through ranges columns hotherps[_32_] Excel Programming 1 February 26th 04 10:52 PM
How do I delete rows and columns in With With End Loop? Bob Benjamin Excel Programming 3 November 16th 03 12:26 AM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"