LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting Data


doing this type of exercise is usually don e better by using a find to
match the columns. Try this code. The items that matched I put an X in
column c. If you need the non matched items I can mdoify the code to
take the items without an X a move them to the bottom of the new list.


Sub SortColumns()

Set sht1 = Sheets("Sheet1")
Set Sht2 = Sheets("Sheet2")


'copy column A to sheet 2
sht1.Columns("A").Copy _
Destination:=Sht2.Columns("A")

With Sht2
'lookup column A on sht2 with column b on sht1
RowCount = 1
Do While .Range("A" & RowCount) < ""
Folder = .Range("A" & RowCount)
Set c = sht1.Columns("B").Find(what:=Folder, _
LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
.Range("B" & RowCount) = c
'put Match into column C on sheet 1
c.Offset(0, 1) = "X"
End If

RowCount = RowCount + 1
Loop
End With


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=149008



 
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
Sorting Data Curtis Stevens Excel Discussion (Misc queries) 3 August 23rd 08 01:22 PM
Sorting data activtodd Excel Discussion (Misc queries) 3 September 19th 06 06:35 PM
Sorting data to match existing data Jack C Excel Discussion (Misc queries) 4 May 24th 06 09:48 AM
colors of bar charted data don't follow data after sorting Frankgjr Charts and Charting in Excel 2 January 17th 06 12:33 PM
Sorting Data vik Excel Worksheet Functions 6 September 9th 05 04:18 PM


All times are GMT +1. The time now is 01:17 PM.

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"