View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Carl Carl is offline
external usenet poster
 
Posts: 361
Default Macro Question ??

Thank you Joel.

The code got hung up he

Sub addnewcolumns()



For Each ws In Worksheets

With Sheets(ws.Name)



For RowCount = 10 To 1000



If .Cells(RowCount, "D") 0.08 Then



.Cells(RowCount, "J") = .Cells(RowCount, "D")

Else

Code Hung Up He

If (.Cells(RowCount, "A") = .Cells(RowCount, "IWM")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QQQQ")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "SPY")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "AAPL")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "DNDN")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QCOM")) Then



.Cells(RowCount, "O") = 0.08

Else

.Cells(RowCount, "O") = .Cells(RowCount, "D")



End If



End If



If .Cells(RowCount, "D") <= 0.08 Then

If (.Cells(RowCount, "A") = .Cells(RowCount, "IWM")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QQQQ")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "SPY")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "AAPL")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "DNDN")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QCOM")) Then



.Cells(RowCount, "P") = .Cells(RowCount, "E") - (0.08 / 2)

End If

End If





If .Cells(RowCount, "D") <= 0.08 Then

If (.Cells(RowCount, "A") = .Cells(RowCount, "IWM")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QQQQ")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "SPY")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "AAPL")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "DNDN")) Or _

(.Cells(RowCount, "A") = .Cells(RowCount, "QCOM")) Then



.Cells(RowCount, "O") = .Cells(RowCount, "F") - (0.08 / 2)

End If

End If



.Cells(RowCount, "Q") = .Cells(RowCount, "G")

.Cells(RowCount, "R") = .Cells(RowCount, "H")

.Cells(RowCount, "S") = .Cells(RowCount, "I")





Next RowCount



End With



Next ws





End Sub



"Joel" wrote:

Sub addnewcolumns()

For Each ws In Worksheets
With Sheets(ws.Name)

For RowCount = 10 To 1000

If .Cells(RowCount, "D") 0.08 Then

.Cells(RowCount, "J") = .Cells(RowCount, "D")
Else
If (.Cells(RowCount, "A") = .Cells(RowCount, "B")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "C")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "E")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "F")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "G")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "H")) Then

.Cells(RowCount, "J") = 0.08
Else
.Cells(RowCount, "J") = .Cells(RowCount, "D")

End If

End If

If .Cells(RowCount, "D") <= 0.08 Then
If (.Cells(RowCount, "A") = .Cells(RowCount, "B")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "C")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "D")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "F")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "G")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "H")) Then

.Cells(RowCount, "K") = .Cells(RowCount, "E") - (0.08 / 2)
End If
End If


If .Cells(RowCount, "D") <= 0.08 Then
If (.Cells(RowCount, "A") = .Cells(RowCount, "B")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "C")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "D")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "F")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "G")) Or _
(.Cells(RowCount, "A") = .Cells(RowCount, "H")) Then

.Cells(RowCount, "L") = .Cells(RowCount, "F") - (0.08 / 2)
End If
End If

.Cells(RowCount, "M") = .Cells(RowCount, "G")
.Cells(RowCount, "N") = .Cells(RowCount, "H")
.Cells(RowCount, "O") = .Cells(RowCount, "I")


Next RowCount

End With

Next ws


End Sub


"carl" wrote:


My workbook contains 10 worksheets. Each worksheet is identical but
represents a different day.



Each worksheet has a table in in A10:I1000



I am trying to create a new table in J10:O1000 that will do this:



For Col J of the new table, if the value in ColA is equal to A,B,C,E;F;G, or
H (or a list of items I have) and the value in ColD is less than or equal to
.08, return .08, otherwise return the value in ColD



For Col K of the new table, if the value in ColA is equal to A,B,C,E;F;G, or
H and the value in ColD is less than or equal to .08, return ColE minus (.08
divided by 2)



For Col L of the new table, if the value in ColA is equal to A,B,C,E;F;G, or
H and the value in ColD is less than or equal to .08, return ColF minus (.08
divided by 2)



For Col M,N and O, return the values from Col G,H,I respectively.



I would like to perform this operation on all selected worksheets.





Thank you in advance.