Search another column for the same value and then skip to the nearest cell

Laurence D

New Member
Joined
Sep 14, 2016
Messages
31
Hi there,

I have some code that is speeding up some checks that I do every week over 1000 rows etc. I am just after a little help in speeding up my checks as this is tedious work. What I am after is for a macro to check if the the previous column (i.e. Column R) has the same value in it and and then if it does search the sequential column (column S) to identify whether there are any of those rows are empty (the red down below symbolises empty rows). if they are empty move the active cell to the nearest cell. If not empty then just move down to the nearest empty cell in that row (skipping hidden cells).

I have most of the code flying around I am just getting stuck on how to search for the same value in the previous column. Here is a table trying to illustrate what I am after

RS
1201901208Where it should go when working
2201901208Completed
3201901208Completed
4201901208Where the macro started
5201955515Completed
6201955515Completed
7201955515If S1 is not empty then skip to this cell

<tbody>
</tbody>


This is the code I have so far

Code:
Sub Selection_Completed()
   
   Application.ScreenUpdating = False
   
    If IsEmpty(ActiveCell) = False Then
           Do Until IsEmpty(ActiveCell)
          ActiveCell.Offset(1, 0).Select
    Loop
    Exit Sub
    End If
   
   Dim rng As range, cell As range
   Set rng = Selection
   For Each cell In rng
        cell.Value = "Completed"
   Next cell
 
    If IsEmpty(ActiveCell.Offset(1, 0)) = True Then
        ActiveCell.Offset(1, 0).Select
    Do Until ActiveCell.EntireRow.Hidden = False
        ActiveCell.Offset(1, 0).Select
    Loop
    End if

    Application.ScreenUpdating = True
   
End Sub

Thanks for the help, Laurence
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,

Not sure to fully understand your constraints ... :wink:

However ... given your number of rows ... there is an obvious recommendation to speed up your whole process :

Forget about your loops ... and use Filter ... :)

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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