Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Need Macro Help

I want the following Macro to copy information from column A:F based on a
repeat reference in column A, paste data beginning in the column G, Add a
sheet, paste in new sheet, go back to Sheet1 and delete A:F. All is working
fine except the Macro is only copying the information in columns A and B.

What do I need to do to get my desired result?

SAMPLE DATA
Column A Column B Column C Column D Column E Column F
111-11-1111 John Andrews Chicago CS Tech
111-11-1111 Daniel Edwards Philadelphia IT Mgr
222-22-2222 Elias Martin Charlotte IT Sup
333-33-3333 Augusta Clemens Philadelphia CS Tech
333-33-3333 Jaime Turner Boston IT Sup
333-33-3333 Wayne Norriston Atlanta DR Dir
RESULT I RECEIVE WITH THE MACRO BELOW:
Column A Column B Column C Column D Column E Column F
111-11-1111 John Daniel
222-22-2222 Elias
333-33-3333 Augusta Jaime Wayne CS Tech
RESULT I WANT:
Column A Column B Column C Column D Column E Column F Column G Column
H Column I Column J Column K Column L Column M Column N Column O Column P
111-11-1111 John Andrews Chicago CS Tech Daniel Edwards Philadelphia IT Mgr
222-22-2222 Elias Martin Charlotte IT Sup
333-33-3333 Augusta Clemens Philadelphia CS Tech Jaime Turner Boston IT Sup Wayne Norriston Atlanta DR Dir

Sub ReArrange()
Dim FirstCell As Range
Dim LastCell As Range
Dim Dest As Range
Dim c As Long
Set FirstCell = Range("A1")
Do Until FirstCell.Value = ""
For c = 1 To 20
If FirstCell.Offset(c).Value < FirstCell.Value Then
Set LastCell = FirstCell.Offset(c - 1)
Set Dest = Range("G" & Rows.Count).End(xlUp).Offset(1)
Exit For
End If
Next c
Dest.Value = FirstCell.Value
For c = 1 To Range(FirstCell, LastCell).Count
Dest.Offset(, c).Value = FirstCell.Offset(c - 1, 1).Value
Next c
Set FirstCell = LastCell.Offset(1)
Loop
Columns("A:F").Select
Columns("A:F").Copy
Sheets.Add
Range("A1").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Columns("A:F").Delete
MsgBox "Run Complete"
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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


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