Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 410
Default VBA to move and concatenate

I am looking to move data from one workbook to another and consolidate
data.

Here is what I have
A = Item #
B = Catalog

Row 1 is A = 1234 and B = 1
Row 2 is A = 1235 and B = 2
Row 3 is A = 1236 and B = 1

What I want
New Workbook
Row 1 is A = 1234, 1236 and B = 1
Row 2 is A = 1235 and B = 2

Thanks,
Jay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA to move and concatenate


Sub combine()

folder = "C:\temp\test\"
Filename = "abc_1.xls"

Workbooks.Open Filename:=folder & Filename
Set oldbk = ActiveWorkbook

With ThisWorkbook
oldbk.ActiveSheet.Copy _
after:=.Sheets(.Sheets.Count)
Set newsht = .ActiveSheet

oldbk.Close

newsht.Cells.Sort _
Key1:=Range("B1"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("B" & RowCount) = _
Range("B" & (RowCount + 1)) Then

data = Range("A" & (RowCount + 1))
If Range("A" & RowCount) = "" Then
Range("A" & RowCount) = data
Else
Range("A" & RowCount) = _
Range("A" & RowCount) & ", " & data
End If
Rows(RowCount + 1).Delete
Else
RowCount = RowCount + 1
End If
Loop

End With

End Sub

"jlclyde" wrote:

I am looking to move data from one workbook to another and consolidate
data.

Here is what I have
A = Item #
B = Catalog

Row 1 is A = 1234 and B = 1
Row 2 is A = 1235 and B = 2
Row 3 is A = 1236 and B = 1

What I want
New Workbook
Row 1 is A = 1234, 1236 and B = 1
Row 2 is A = 1235 and B = 2

Thanks,
Jay

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
Excel arrows don't move black box but move the window Thebit Excel Discussion (Misc queries) 1 April 13th 09 02:06 AM
excel-how to get the spreadsheet to move as I move the scroll tab excel toiler Excel Discussion (Misc queries) 6 November 7th 07 06:07 PM
How do I stop making the spreadsht move when I move up/dwn/lt/rt? Manny Excel Worksheet Functions 4 April 7th 06 10:30 PM
I know how to concatenate ,can one de-concatenate to split date? QUICK BOOKS PROBLEM- New Users to Excel 1 July 26th 05 05:07 PM
When I move scroll bar in excell the contents do not move with it ramneek Excel Discussion (Misc queries) 2 June 29th 05 07:35 PM


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