View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Copy Values Between Worksheets in same Workbook

Sub move_to_discount()

Const CostCode = 7234
Const DiscountCode = 7346

With Sheets("Discount")
DisLastRow = .Cells(Rows.Count, "C").End(xlUp).Row
End With

DisRowCount = DisLastRow + 1

With Sheets("Sheet1")
Sh1LastRow = .Cells(Rows.Count, "B").End(xlUp).Row

For Sh1RowCount = 2 To Sh1LastRow
ItemDate = .Cells(Sh1RowCount, "B")
Cost = .Cells(Sh1RowCount, "E")
Discount = .Cells(Sh1RowCount, "K")

With Sheets("Discount")
.Cells(DisRowCount, "C") = ItemDate
.Cells(DisRowCount, "F") = Cost
.Cells(DisRowCount, "G") = CostCode
DisRowCount = DisRowCount + 1
.Cells(DisRowCount, "C") = ItemDate
.Cells(DisRowCount, "F") = Discount
.Cells(DisRowCount, "G") = DiscountCode
DisRowCount = DisRowCount + 1
End With

Next Sh1RowCount
End With

End Sub


"Joe K." wrote:


Please help me create a macro that will have the source Worksheet as
Sheet1 and the destination worksheet as discount that corresponds to the
data listed below. Each row from Sheet1 corresponds to two rows in Discount
worksheet.

Every row that corresponds to Cost column (E) has a Cost Code = 0007346
and Discount column (K) has a Discount Code = 0007346 and this value place
in the Column G of the Discount worksheet.

The Sheet1 usually has 60 days of data.

Thanks,



Category
Cost Code = 0007234
Discount Code = 0007346


Worksheet(Sheet1)
Date(B06) Cost(E06) Discount(K06)
01/01/2003 5.67 1.32
01/02/2003 15.24 3.34
01/03/2003 12.13 2.09
...
03/01/2003 8.48 1.68

Worksheet(Discount)

Col(C) Date Col(F) Cost Col(G) Category
01/01/2003 5.67 0007234
01/01/2003 1.32 0007346
01/02/2003 15.24 0007234
01/02/2003 3.34 0007346
01/03/2003 12.13 0007234
01/03/2003 2.09 0007346
...
03/01/2003 8.48 0007234
03/01/2003 1.68 0007346