Hi I would like to ask for help with following situation:
I have a code, which runs the operation (comparing the value of specified cell with values from other specified column and then write appropriate value to other cell.
This code is fine for one specified cell, however I have 5152 such cells which needs to be evaluated (N2:N5152).
What I need to do is to adjust the following code, so it will do the specified operation for first cell, then go down to other cell and do the same, and so for each of the 5152 cells in column.
The code is: (assigned to button)
The code compares value in cell N2 with values in column A in sheet 2 and if it finds first which is higher or at least equal, then it writes the value of specified cell in column G.
I need to write it, so this will be repeated for every cell from N2 to N5152. I don´t know how to specify how to go to cell N3, N4... and repeat the process for them.
thanks for any help
I have a code, which runs the operation (comparing the value of specified cell with values from other specified column and then write appropriate value to other cell.
This code is fine for one specified cell, however I have 5152 such cells which needs to be evaluated (N2:N5152).
What I need to do is to adjust the following code, so it will do the specified operation for first cell, then go down to other cell and do the same, and so for each of the 5152 cells in column.
The code is: (assigned to button)
Code:
Private Sub button_Click()
Dim i, Poz As Integer
i = 2
Poz = 0
Do While Worksheets("sheet2").Range("A" & i) <> ""
Poz = Poz + 1
i = i + 1
Loop
For i = 2 To Poz
If Worksheets("sheet1").Range("N2") = "0" Then
Worksheets("sheet1").Range("O2") = "0"
ElseIf Worksheets("sheet1").Range("N2") <= Worksheets("sheet2").Range("A" & i) Then
Worksheets("sheet1").Range("O2") = Worksheets("sheet2").Range("G" & i)
Exit For
Else
End If
Next i
End Sub
The code compares value in cell N2 with values in column A in sheet 2 and if it finds first which is higher or at least equal, then it writes the value of specified cell in column G.
I need to write it, so this will be repeated for every cell from N2 to N5152. I don´t know how to specify how to go to cell N3, N4... and repeat the process for them.
thanks for any help