What I am trying to do: Find where a row has the name "Craig Bethune" in it then select the corresponding cells in column M,O,Q,S and U (this will open a "new sheet") Copy the data that is opened and paste it in the next open row in a sheet called "Prime Broker"
My Problem: It seems like the macro is skipping over some cells in the corresponding columns with a number greater than 0.
Another wierd thing is it starts at a15 instead of a1 on the prime broker sheet.
Here is my Macro code, including the creation of the new sheet
Sub Problem()
'
'select daily summary tab and add new sheet
'
'
Sheets("Daily Summary by Value Date").Select
Sheets.Add
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Prime Broker"
Sheets("Daily Summary by Value Date").Select
'
'copy and paste info from daily values into Prime Broker sheet
'
'
Dim cell As Range, area As Range, x As Integer
x = 0
Set area = Sheets("Daily Summary by Value Date").Range("l1:l250")
For Each cell In area
If cell.Value = "Craig Bethune" Then
'Cell M
If cell.Offset(0, 13) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 13).Select
'x = x + cell.Offset(0, 13)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(1, 0).Select
ActiveSheet.Paste
End If
'cell O
If cell.Offset(0, 15) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 15).Select
'x = x + cell.Offset(0, 15)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell Q
If cell.Offset(0, 17) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 17).Select
'x = x + cell.Offset(0, 17)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell S
If cell.Offset(0, 19) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 19).Select
'x = x + cell.Offset(0, 19)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell U
If cell.Offset(0, 21) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 21).Select
'x = x + cell.Offset(0, 21)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'x = x + 1
End If
Next cell
End Sub
any help would be greatly appreciated
My Problem: It seems like the macro is skipping over some cells in the corresponding columns with a number greater than 0.
Another wierd thing is it starts at a15 instead of a1 on the prime broker sheet.
Here is my Macro code, including the creation of the new sheet
Sub Problem()
'
'select daily summary tab and add new sheet
'
'
Sheets("Daily Summary by Value Date").Select
Sheets.Add
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Prime Broker"
Sheets("Daily Summary by Value Date").Select
'
'copy and paste info from daily values into Prime Broker sheet
'
'
Dim cell As Range, area As Range, x As Integer
x = 0
Set area = Sheets("Daily Summary by Value Date").Range("l1:l250")
For Each cell In area
If cell.Value = "Craig Bethune" Then
'Cell M
If cell.Offset(0, 13) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 13).Select
'x = x + cell.Offset(0, 13)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(1, 0).Select
ActiveSheet.Paste
End If
'cell O
If cell.Offset(0, 15) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 15).Select
'x = x + cell.Offset(0, 15)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell Q
If cell.Offset(0, 17) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 17).Select
'x = x + cell.Offset(0, 17)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell S
If cell.Offset(0, 19) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 19).Select
'x = x + cell.Offset(0, 19)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'cell U
If cell.Offset(0, 21) > 0 Then
Sheets("Daily Summary by Value Date").Select
cell.Offset(0, 21).Select
'x = x + cell.Offset(0, 21)
Selection.ShowDetail = True
Selection.Copy
Sheets("Prime Broker").Select
Range("a1").Offset(x, 0).Select
ActiveSheet.Paste
End If
'x = x + 1
End If
Next cell
End Sub
any help would be greatly appreciated