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.
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

RickXL

MrExcel MVP
Joined
Sep 9, 2013
Messages
4,328
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,318
Messages
5,600,925
Members
414,416
Latest member
Nobu

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
Top