by cjones198 » Sun Sep 27, 2020 2:00 pm
sorry captain, that variable switch market i had not declared it as "static" silly error
so page one "Market" i designate 2 cells in sheet "selection"
E4 is current price
E5 is current matched
on my manual sheet the only piece of code i had on "market" was
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
If Sheets("Market").Cells(2, 5).Value = "In Play" Then
Exit Sub
End If
x = Sheets("Selection").Cells(2, 5).Value + 4
Sheets("Selection").Cells(4, 4).Value = Sheets("Market").Cells(x, 15).Value
Sheets("Selection").Cells(5, 4).Value = Sheets("Market").Cells(x, 16).Value
End Sub
then the bulk of code was in sheet selection which is
Private Sub Worksheet_Change(ByVal Target As Range)
If Price = Empty Then 'If no start price recorded dont do anything
Exit Sub
End If
If EventID <> Sheets("market").Cells(1, 1).Value Then 'If the event changes stop reocording
Price = Empty
Exit Sub
End If
If Sheets("Selection").Cells(8, 4).Value = "STOP" Then
Exit Sub
End If
Application.EnableEvents = False
If Sheets("Selection").Cells(6, 4).Value >= "0.5" Then 'if 2 or more ticks selected
If Sheets("Selection").Cells(4, 4).Value >= 1.01 And Sheets("Selection").Cells(4, 4).Value <= 2 Then
Sheets("Selection").Cells(1, 10).Value = "0.01"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 2.02 And Sheets("Selection").Cells(4, 4).Value <= 3 Then
Sheets("Selection").Cells(1, 10).Value = "0.02"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 3.05 And Sheets("Selection").Cells(4, 4).Value <= 4 Then
Sheets("Selection").Cells(1, 10).Value = "0.05"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 4.1 And Sheets("Selection").Cells(4, 4).Value <= 6 Then
Sheets("Selection").Cells(1, 10).Value = "0.1"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 6.2 And Sheets("Selection").Cells(4, 4).Value <= 10 Then
Sheets("Selection").Cells(1, 10).Value = "0.2"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 10.5 And Sheets("Selection").Cells(4, 4).Value <= 20 Then
Sheets("Selection").Cells(1, 10).Value = "0.5"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 21 And Sheets("Selection").Cells(4, 4).Value <= 30 Then
Sheets("Selection").Cells(1, 10).Value = "1"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 32 And Sheets("Selection").Cells(4, 4).Value <= 50 Then
Sheets("Selection").Cells(1, 10).Value = "2"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 55 And Sheets("Selection").Cells(4, 4).Value <= 100 Then
Sheets("Selection").Cells(1, 10).Value = "5"
ElseIf Sheets("Selection").Cells(4, 4).Value >= 110 And Sheets("Selection").Cells(4, 4).Value <= 1000 Then
Sheets("Selection").Cells(1, 10).Value = "10"
End If 'work out the tick increments
'Start to lay
If Price <> Sheets("Selection").Cells(4, 4).Value And Price <= Sheets("Selection").Cells(4, 4).Value - (Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value) And Sheets("Selection").Cells(11, iCol - 1).Value = "start" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "l"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x - 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 38
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
Sheets("Renko").Cells(x, iPriceRange).Value = Sheets("Selection").Cells(10, iCol - 1).Value & sep & Price
With Sheets("Renko")
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Merge
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Orientation = 90
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).WrapText = False
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Merge
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Orientation = 90
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).WrapText = False
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).ShrinkToFit = True
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x + 9, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x + 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
'Start to back
ElseIf Price <> Sheets("Selection").Cells(4, 4).Value And Price >= Sheets("Selection").Cells(4, 4).Value + (Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value) And Sheets("Selection").Cells(11, iCol - 1).Value = "start" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "b"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x - 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 24
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
Sheets("Renko").Cells(x, iPriceRange).Value = Price & sep & Sheets("Selection").Cells(10, iCol - 1).Value
With Sheets("Renko")
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Merge
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Orientation = 90
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).WrapText = False
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Merge
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Orientation = 90
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).WrapText = False
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x - 11, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x - 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
'lay to lay
ElseIf Price <> Sheets("Selection").Cells(4, 4).Value And Price <= (Sheets("Selection").Cells(4, 4).Value - (Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value)) And Sheets("Selection").Cells(11, iCol - 1).Value = "l" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "l"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x - 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 38
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
If Sheets("Renko").Cells(x, iPriceRange).Value = "" Then
Sheets("Renko").Cells(x, iPriceRange).Value = Sheets("Selection").Cells(10, iCol - 1).Value & sep & Price
End If
With Sheets("Renko")
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Merge
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Orientation = 90
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).WrapText = False
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Merge
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Orientation = 90
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).WrapText = False
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x + 9, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x + 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
'back to back
ElseIf Price <> Sheets("Selection").Cells(4, 4).Value And Price >= (Sheets("Selection").Cells(4, 4).Value + (Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value)) And Sheets("Selection").Cells(11, iCol - 1).Value = "b" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "b"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x + 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 24
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
If Sheets("Renko").Cells(x, iPriceRange).Value = "" Then
Sheets("Renko").Cells(x, iPriceRange).Value = Price & sep & Sheets("Selection").Cells(10, iCol - 1).Value
End If
With Sheets("Renko")
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Merge
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Orientation = 90
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).WrapText = False
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Merge
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Orientation = 90
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).WrapText = False
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x - 11, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x - 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
'back to lay
ElseIf Price <> Sheets("Selection").Cells(4, 4).Value And Price <= (Sheets("Selection").Cells(4, 4).Value - ((Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value) * 2)) And Sheets("Selection").Cells(11, iCol - 1).Value = "b" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "l"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x - 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 38
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
If Sheets("Renko").Cells(x, iPriceRange).Value = "" Then
Sheets("Renko").Cells(x, iPriceRange).Value = (Price - Sheets("Selection").Cells(6, 4).Value * Sheets("Selection").Cells(1, 10).Value) & sep & Price
End If
With Sheets("Renko")
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Merge
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Orientation = 90
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).WrapText = False
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x + 3, i), .Cells(x + (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Merge
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Orientation = 90
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).WrapText = False
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x + 9, i), .Cells(x + (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x + 9, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x + 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
'lay to back
ElseIf Price <> Sheets("Selection").Cells(4, 4).Value And Price >= (Sheets("Selection").Cells(4, 4).Value + ((Sheets("Selection").Cells(1, 10).Value * Sheets("Selection").Cells(6, 4).Value) * 2)) And Sheets("Selection").Cells(11, iCol - 1).Value = "l" Then 'if the price changes from last price record and move on to next col
Sheets("Selection").Cells(10, iCol).Value = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(11, iCol).Value = "b"
Price = Sheets("Selection").Cells(4, 4).Value
Sheets("Selection").Cells(12, iCol).Value = Sheets("Selection").Cells(5, 4).Value
Sheets("Selection").Cells(13, iCol).Value = Sheets("Selection").Cells(5, 4).Value - Sheets("Selection").Cells(12, iCol - 1).Value
Sheets("Selection").Cells(14, iCol).Value = Sheets("Selection").Cells(13, iCol).Value / Sheets("Selection").Cells(12, iCol).Value
Sheets("Selection").Cells(15, iCol).Value = Sheets("Market").Cells(2, 4).Value
i = i + 1
x = x + 1
Sheets("Renko").Cells(x, i).Interior.ColorIndex = 24
Sheets("Renko").Cells(3, i).Value = Sheets("Selection").Cells(15, iCol).Value
Sheets("Renko").Cells(x, iVolMatch).Value = Sheets("Selection").Cells(16, iCol).Value
If Sheets("Renko").Cells(x, iPriceRange).Value = "" Then
Sheets("Renko").Cells(x, iPriceRange).Value = Price & sep & (Price + Sheets("Selection").Cells(6, 4).Value * Sheets("Selection").Cells(1, 10).Value)
End If
With Sheets("Renko")
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Merge
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Orientation = 90
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).WrapText = False
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).NumberFormat = "$#,##0.00_);($#,##0)"
.Range(.Cells(x - 3, i), .Cells(x - (3 + 5), i)).Value = Sheets("Selection").Cells(13, iCol).Value
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Merge
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Orientation = 90
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).WrapText = False
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).VerticalAlignment = xlBottom
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).HorizontalAlignment = xlCenter
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).NumberFormat = "0.01%"
.Range(.Cells(x - 9, i), .Cells(x - (9 + 2), i)).Value = Sheets("Selection").Cells(14, iCol).Value
If Sheets("Renko").Cells(x - 11, i).Value >= Sheets("Selection").Cells(7, 4).Value Then
Sheets("Renko").Cells(x - 12, i).Interior.ColorIndex = 4
End If
End With
iCol = iCol + 1
End If
End If
Application.EnableEvents = True
End Sub
at present on the auto recording sheet im making if i code anything into sheet named selection, nothing happens on the shete its as if the code is not working at all, only things written within sheet called Market work