PC Review


Reply
Thread Tools Rate Thread

Copy data from Workbook Alpha & reorganize it in Workbook Bravo

 
 
u473
Guest
Posts: n/a
 
      30th Oct 2007
Copy data from Workbook Alpha,
and summarize / reorganize it in Workbook Bravo.

Data Source :
Workbook Alpha Sheet1
Code Desc Cost
A1 Equipt. x 500
A2 Freight 200
B1 Equipt. y 700
B2 Freight 100

How do I group data on Left(Code,1), and,
If the Code suffix is 1, assign Cost to the Equipt. Cost Column
If the Code suffix is 2, assign Cost to the Freight Cost Column

Desired Result in Workbook Bravo Sheet1
Code Desc Equipt.Cost Freight Total
A Equipt. x 500 200 700
B Equipt. y 700 100 800

Thank you for your help,

Wayne

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      31st Oct 2007

Sub summarize()

With Workbooks("Alpha.xls").Sheets("Sheet1")
LastRowAlpha = .Cells(Rows.Count, "A").End(xlUp).Row
For AlphaRowCount = 2 To LastRowAlpha
code = Left(.Cells(AlphaRowCount, "A"), 1)
suffix = Mid(.Cells(AlphaRowCount, "A"), 2)
Desc = .Cells(AlphaRowCount, "B")
Cost = .Cells(AlphaRowCount, "C")

With Workbooks("Bravo.xls").Sheets("Sheet1")
LastRowBravo = .Cells(Rows.Count, "A").End(xlUp).Row

Set SearchRange = .Range("A2:A" & LastRowBravo)
Set c = SearchRange.Find(what:=code, LookIn:=xlValues)
If c Is Nothing Then
DataRow = LastRowBravo + 1
.Range("A" & DataRow) = code
Else
DataRow = c.Row
End If

If suffix = 1 Then
.Range("A" & DataRow) = code
.Range("B" & DataRow) = Desc
.Range("C" & DataRow) = Cost
.Range("E" & DataRow).Formula = _
"=C" & DataRow & _
"+D" & DataRow
Else
.Range("D" & DataRow) = Cost
End If
End With
Next AlphaRowCount
End With

End Sub

"u473" wrote:

> Copy data from Workbook Alpha,
> and summarize / reorganize it in Workbook Bravo.
>
> Data Source :
> Workbook Alpha Sheet1
> Code Desc Cost
> A1 Equipt. x 500
> A2 Freight 200
> B1 Equipt. y 700
> B2 Freight 100
>
> How do I group data on Left(Code,1), and,
> If the Code suffix is 1, assign Cost to the Equipt. Cost Column
> If the Code suffix is 2, assign Cost to the Freight Cost Column
>
> Desired Result in Workbook Bravo Sheet1
> Code Desc Equipt.Cost Freight Total
> A Equipt. x 500 200 700
> B Equipt. y 700 100 800
>
> Thank you for your help,
>
> Wayne
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy specific data from master workbook to another workbook Mark767 Microsoft Excel Programming 13 1st Sep 2009 08:57 PM
1.Open workbook. 2 copy data. 3 replace data. 4 save workbook. Cristobalitotom Microsoft Excel Programming 0 6th Jul 2006 12:24 AM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Microsoft Excel Programming 1 1st Apr 2006 08:48 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Microsoft Excel Misc 1 16th Mar 2006 06:55 PM
Lose data when copy and paste from workbook to workbook =?Utf-8?B?QWt3YWk=?= Microsoft Excel Misc 2 26th Feb 2004 12:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 AM.