ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Select (https://www.excelbanter.com/excel-programming/397826-macro-select.html)

tc

Macro to Select
 
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!


joel

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!




All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com