LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Adjust code to run anywhere on sheet

This code works fine on a list with a Header in column A.
Copies the Header across the same row, starting 1 column to the right for as many columns as there are items in the list.
Cuts the items in the list to the right on a "slant" 1 column over and 1 row down until end of list.

So now the OP says the list will not always be in the same range but wants the code to do as it does here as I have posted. The lists to processed will be in different columns and not always starting at row 1.

I tried using 'For Each c In Selection' but I cannot figure out how to identify the header in the Selection to copy across as needed.

Thanks.
Howard

Option Explicit

Sub cLant()

Dim c As Range
Dim i As Long
Dim rCt As Range

Set rCt = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)

i = 0
For Each c In rCt
c.Cut c.Offset(, i)
Range("A1").Copy Range("A1").Offset(, i)
i = i + 1
Next

End Sub
 
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
Adjust Zip code to 9 Char fmt. Jeffery B Paarsa Excel Programming 11 May 28th 09 06:50 PM
help to adjust my code Anthony Excel Programming 2 March 14th 07 09:20 PM
Help to adjust code SiouxieQ Excel Programming 0 November 27th 04 07:45 PM
HELP - I need to adjust code!!!! jriendeau5[_3_] Excel Programming 1 November 5th 04 02:29 AM


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