#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default loop

how to make loop (macro),
raw
13035 13031
13035 13037
13036 13056
13037 13251
13037 13298
13037 13299
13044 13282
13075 13275
13048 13031
13048 13055
13099 13066
13099 13077
13099 13252
13099 13692

result

13035 13037 13031
13036 13056
13037 13299 13298 13251
13044 13282
13075 13275
13048 13055 13031
13099 13692 13252 13077 13066


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default loop

Try this one.
I supposed that data is column A and B and start at row 1. the result
will be in the new sheet after activesheet.

Sub movedatatest()
Dim acsh As Worksheet, dstsh As Worksheet
Dim i As Long, j As Long

Set acsh = ActiveSheet
Set dstsh = Worksheets.Add(after:=acsh)
acsh.Select

lastrow = Range("A1").End(xlDown).Row
j = 1
i = 1
dstsh.Cells(j, "A") = Cells(i, "A")
dstsh.Cells(j, "B") = Cells(i, "B")
For i = 2 To lastrow
If Cells(i, "A") = dstsh.Cells(j, "A") Then
Cells(i, "B").Copy
dstsh.Cells(j, "B").Insert Shift:=xlToRight
Else
j = j + 1
dstsh.Cells(j, "A") = Cells(i, "A")
dstsh.Cells(j, "B") = Cells(i, "B")
End If
Next
Application.CutCopyMode = False
End Sub

keiji

Skipper wrote:
how to make loop (macro),
raw
13035 13031
13035 13037
13036 13056
13037 13251
13037 13298
13037 13299
13044 13282
13075 13275
13048 13031
13048 13055
13099 13066
13099 13077
13099 13252
13099 13692

result

13035 13037 13031
13036 13056
13037 13299 13298 13251
13044 13282
13075 13275
13048 13055 13031
13099 13692 13252 13077 13066


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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


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