Walking through a column row by row.

bountiful

New Member
Joined
Jun 18, 2015
Messages
31
So hopefully you can see what I'm trying to do. The title pretty much describes it all. Plz halp

Code:
Sub changeData()
    'Application.ScreenUpdating = False ' faster for modifying values on sheet
    Dim header As String
    Dim numRows As Long
    Dim col As Long, y As Long, a As Integer
    Dim c As Excel.Range
    header = "Search:" ' header name to find
    Set c = ActiveSheet.Range("1:1").Find(header, LookIn:=xlValues)
    If Not c Is Nothing Then
        col = c.Column
        'y = Range(c.Offset(1), c.End(xlDown))
        c.Offset(1).Select
        
    Else
        ' can't work with it
        Exit Sub
    End If
    a = 1
    While c(a) <> ""
        c(a).Select
        If c(a) = c.Offset(a + 1) Then
        c(a).Offset(0, 1) = "IT WORKED"
        a = a + 1
        Else
        a = a + 1
        End If
    ' (whatever this is)
    Wend
you see, my problem is that it's skipping some of the steps that it should do.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,

I think you are trying to do this:

Code:
Sub changeData()
    'Application.ScreenUpdating = False ' faster for modifying values on sheet
    Dim header As String
    Dim numRows As Long
    Dim col As Long, y As Long, a As Integer
    Dim c As Excel.Range
    header = "Search:" ' header name to find
    Set c = ActiveSheet.Range("1:1").Find(header, LookIn:=xlValues)
    If Not c Is Nothing Then
        col = c.Column
        'y = Range(c.Offset(1), c.End(xlDown))
        c.Offset(1).Select
        
    Else
        ' can't work with it
        Exit Sub
    End If
    a = 1
    While c(a) <> ""
        c(a).Select
        If c(a) = c.Offset(1) Then
            c(a).Offset(0, 1) = "IT WORKED"
            a = a + 1
        Else
            a = a + 1
        End If
    ' (whatever this is)
    Wend
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,927
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top