Thread: Macro to Select
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Macro to Select

Sub test()

Sh2RowCount = 1
With Sheets("Sheet1")
Lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
For RowCount = 1 To Lastrow
If .Cells(RowCount, "A").Value < "" Then
MyName = .Cells(RowCount, "A").Value
Else
Subtotal = .Cells(RowCount, "B").Value

With Sheets("Sheet2")
.Cells(Sh2RowCount, "A").Value = MyName
.Cells(Sh2RowCount, "B").Value = Subtotal
End With
Sh2RowCount = Sh2RowCount + 1
End If
Next RowCount
End With
End Sub

"tc" wrote:

hi. i have a worksheet which contains two columns, one with names and
the other with amounts, there is an empty cell between unique names
but thre is no empty cell in between amounts because of subtotals. i
need to create a macro that will select each of the unique names(may
occupy one or more rows) and the coresponding amounts and paste them
to a seperate worksheet. please help!