Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default select columns by text in first cell

I'm trying to select a whole column (and eventually only the filled
cells) by the text on its first row. The code I have by now is this:
--
For Each col In Worksheets
Select Case Columns.Name
Case "text-in-first-cell"
Columns.Select
Selection.Copy
MsgBox "The selection object type is " &
TypeName(Selection)
End Select
Next
--

It returns the error "Application-defined or object-defined error".

It's the first time I'm trying to code anything in VB, so any help
would be very appreciated.

Thank you.
Duarte

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default select columns by text in first cell

Dim icol as Long, col as Range
Icol = 1
For Each col In Range("A1:IV1")
Select Case lcase(col.text)
Case "text-in-first-cell"
col.EntireColumn.Copy Worksheets( _
"Destination").Columns(icol)
End Select
Next

--
Regards,
Tom Ogilvy


"zedascouves" wrote:

I'm trying to select a whole column (and eventually only the filled
cells) by the text on its first row. The code I have by now is this:
--
For Each col In Worksheets
Select Case Columns.Name
Case "text-in-first-cell"
Columns.Select
Selection.Copy
MsgBox "The selection object type is " &
TypeName(Selection)
End Select
Next
--

It returns the error "Application-defined or object-defined error".

It's the first time I'm trying to code anything in VB, so any help
would be very appreciated.

Thank you.
Duarte


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default select columns by text in first cell

Thank you! :-D

Tom Ogilvy escreveu:
Dim icol as Long, col as Range
Icol = 1
For Each col In Range("A1:IV1")
Select Case lcase(col.text)
Case "text-in-first-cell"
col.EntireColumn.Copy Worksheets( _
"Destination").Columns(icol)
End Select
Next

--
Regards,
Tom Ogilvy


"zedascouves" wrote:

I'm trying to select a whole column (and eventually only the filled
cells) by the text on its first row. The code I have by now is this:
--
For Each col In Worksheets
Select Case Columns.Name
Case "text-in-first-cell"
Columns.Select
Selection.Copy
MsgBox "The selection object type is " &
TypeName(Selection)
End Select
Next
--

It returns the error "Application-defined or object-defined error".

It's the first time I'm trying to code anything in VB, so any help
would be very appreciated.

Thank you.
Duarte



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
select text in cell based on text from another cell, paste the text at the begining of a thrid cell, etc... jsd219 Excel Programming 0 October 19th 06 05:04 PM
Search & delete ANY text in select columns huruta Excel Discussion (Misc queries) 2 June 30th 06 07:31 PM
Select specific columns for a given cell selection crazybass2 Excel Programming 2 April 21st 05 05:41 PM
Select Columns based on cell value No Name Excel Programming 1 November 13th 03 09:31 AM
Select a range of columns based on active cell Tom Ogilvy Excel Programming 0 November 10th 03 05:09 PM


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