arathore93
New Member
- Joined
- Sep 30, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hello I am fairly new to macros but would love to be apart of the community.
I have a table with 1000 rows and 25 columns A through Y. I am trying to create a macro that will select ALL rows in the table which MUST contain a "0" in the "I" column AND a "2" in the "R" column.
I would then like to get the data from the NEXT ROW UP from the selected rows in the first part of the macro. IF the nextValue in columns "I" is ABOVE 0, sum up how many times and if the value is BELOW 0, sum up how many times.
This is what I have so far:
Sub newCode()
Dim i As Long: i = 1
nextValue As Integer
Dim rng As Range
Do While Range("I" & i).Value = 0 And Range("R" & i).Value = 2
i = i + 1
Loop
Range("I1:I" And "R1:R" & i - 1).EntireRow.End(xlUp).Select
'getting mismatch error
Next
nextValue = rng.Offset(1, 0).Value
If nextValue > 0 Then
'Need help here
ElseIf nextValue < 0 Then
'Need help here
Else
End Sub
I have a table with 1000 rows and 25 columns A through Y. I am trying to create a macro that will select ALL rows in the table which MUST contain a "0" in the "I" column AND a "2" in the "R" column.
I would then like to get the data from the NEXT ROW UP from the selected rows in the first part of the macro. IF the nextValue in columns "I" is ABOVE 0, sum up how many times and if the value is BELOW 0, sum up how many times.
This is what I have so far:
Sub newCode()
Dim i As Long: i = 1
nextValue As Integer
Dim rng As Range
Do While Range("I" & i).Value = 0 And Range("R" & i).Value = 2
i = i + 1
Loop
Range("I1:I" And "R1:R" & i - 1).EntireRow.End(xlUp).Select
'getting mismatch error
Next
nextValue = rng.Offset(1, 0).Value
If nextValue > 0 Then
'Need help here
ElseIf nextValue < 0 Then
'Need help here
Else
End Sub