Rahul87
New Member
- Joined
- Apr 7, 2023
- Messages
- 18
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
Hi Experts, once again thank you very much for helping me in achieving my tasks. Once again I posting here to get another tasks to be done. Please have a look on below requirements and if possible then please help me out.
Any help would be highly appreciated.
In my sheet there are eight columns A, B, C, D, E, F, G, H with heading as Trading Symbol, LTP, ATP, Recorded ATP, Rate, TSL, Reconsideration, and Rank as below.
I want to fetch out the number of data (only Trading symbols) from column A as mentioned by the user in integer value in Cell V5 as (1,2,3.......) for positioning of data in vertical order and also to provide position or rank as 1, 2, 3.... and so on vertically from cell U18,V18.... for ranking or serial number or for positioning as below, and similarly U19, V19.... for trading symbol.
on the basis of below criteria, which will be defined by the user only in other columns/cell as like below snap:-
data should be fetched out and pasted horizontally from Cell U19, V19.........
if percentage value in column E (Rate) is greater than value of Cell V8
and if column B (LTP) value is greater than column G (Reconsideration) And column H (Rank) value is less than or equals to cell value of V5
and if any of the position value in vertical order is vacant then only it should fill the vacant position at last and it should replace or move the existing trading symbol above only when the rank in column H is greater than the out of rank value of Cell V9 and if Value of column B is less than value of column F.
Below is the code, which I am was able to search and build with help of internet, but unable to get it done.
Please help me out in achieving the task. if not understood then please post, I will make it more clear.
Any help would be highly appreciated.
In my sheet there are eight columns A, B, C, D, E, F, G, H with heading as Trading Symbol, LTP, ATP, Recorded ATP, Rate, TSL, Reconsideration, and Rank as below.
I want to fetch out the number of data (only Trading symbols) from column A as mentioned by the user in integer value in Cell V5 as (1,2,3.......) for positioning of data in vertical order and also to provide position or rank as 1, 2, 3.... and so on vertically from cell U18,V18.... for ranking or serial number or for positioning as below, and similarly U19, V19.... for trading symbol.
1 | 2 | 3 | 4 |
BHEL23APRFUT | CHAMBLFERT23APRFUT | BAJAJFINSV23APRFUT | HDFC23APRFUT |
on the basis of below criteria, which will be defined by the user only in other columns/cell as like below snap:-
data should be fetched out and pasted horizontally from Cell U19, V19.........
if percentage value in column E (Rate) is greater than value of Cell V8
and if column B (LTP) value is greater than column G (Reconsideration) And column H (Rank) value is less than or equals to cell value of V5
and if any of the position value in vertical order is vacant then only it should fill the vacant position at last and it should replace or move the existing trading symbol above only when the rank in column H is greater than the out of rank value of Cell V9 and if Value of column B is less than value of column F.
Below is the code, which I am was able to search and build with help of internet, but unable to get it done.
Please help me out in achieving the task. if not understood then please post, I will make it more clear.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
StartTimer
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim dataRange As Range
Set dataRange = Range("A2:H" & Cells(Rows.Count, "H").End(xlUp).Row)
If Target.Address = "$V$5" Then
'Check if the entered value is an integer and not empty and not zero
If IsNumeric(Target.Value) And Target.Value <> "" And Target.Value <> 0 And Int(Target.Value) = Target.Value Then
'Get the threshold, consideration, maxRank, and position values from the worksheet
Dim threshold As Double
threshold = Range("V8").Value
Dim consideration As Double
consideration = Range("G1").Value
Dim maxRank As Long
maxRank = Range("V5").Value
Dim outOfRank As Long
outOfRank = Range("V9").Value
Dim position As Long
position = Range("V5").Value
'Initialize the row counter for writing data to the output range
Dim outputRow As Long
outputRow = 19
'Initialize the serial number
Dim serialNumber As Long
serialNumber = 1
'Loop through the rows in the data range
Dim i As Long
For i = 1 To dataRange.Rows.Count
'Check if the percentage value in the E column is greater than the threshold
If dataRange(i, 5).Value > threshold Then
'Check if the LTP column value is greater than the consideration value
If dataRange(i, 2).Value > consideration Then
'Check if the Rank column value is less than or equal to the maxRank value
If dataRange(i, 8).Value <= maxRank Then
'Check if the position value in the vertical order is vacant
If Range("V" & (position + 18)).Value = "" Then
'Write the serial number and Trading Symbol horizontally to the output range starting at V19
Range("U" & outputRow).Value = serialNumber
Range("V" & outputRow).Value = dataRange(i, 1).Value
'Increment the row and serial number
outputRow = outputRow + 1
serialNumber = serialNumber + 1
'If the position value in the vertical order is not vacant, check if the rank is greater than the outOfRank value and if the LTP is less than TSL
ElseIf dataRange(i, 8).Value > outOfRank And dataRange(i, 2).Value < dataRange(i, 6).Value Then
'Find the next vacant position in the vertical order
Do While Range("V" & (position + 18)).Value <> ""
position = position + 1
Loop
'Write the serial number and Trading Symbol horizontally to the vacant position in the vertical order
Range("U" & (position + 18)).Value = serialNumber
Range("V" & (position + 18)).Value = dataRange(i, 1).Value
'Increment the serial number
serialNumber = serialNumber + 1
End If
End If
End If
End If
Next i
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub