Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

If value in one cell, then modify row which consists that cell

$
0
0

I am totally new to VBA and I am struggling a little bit with one thing. I want to make a macro, which checks values in "M" column. If value is higher than 5, then print "hello". If not then print "x". Unfortunately, I only gets "x" back in selected cells.

Private Sub costam()
Dim i As Integer
Dim a As Integer
a = 13

For i = 1 To Range("M"& Rows.Count).End(xlUp).Row
    If Cells(a, i).Value > 5 Then
     Range(Cells(1, i), Cells(10, i)).Value = "hello"
    Else
     Range(Cells(1, i), Cells(10, i)).Value = "x"
    End If
Next i

End Sub

I know this problem is silly and takes like 1 minute to solve, but I am trying to apply some alike problems but without any progress.


Viewing all articles
Browse latest Browse all 88854


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>