Excluding entire rows from macro based on one column

goblue667

New Member
Joined
Aug 12, 2019
Messages
11
So I have been beating my head against this for a couple of days now. If column R is blank, exclude or ignore that entire record from the code. The problem is, I can get it to work.... if I permentantly delete that row from the sheet. The entire code is very very long so I will only include the necessary parts. Thank you!
P.S: "Remedy" in myarray is that column R that was referenced earlier.

VBA Code:
'Sets Array from "Make-Ready" Sheet
    Sheets("Make-Ready").Select
        Range("A1").Select

        Dim CountRow As Integer
        Dim CountColumn As Integer
        Dim i As Integer
        Dim myarray() As Variant
        lastrow = (Range("A19:A500").SpecialCells(xlCellTypeConstants, xlNumbers).Count) + 19   'This line get the total number of rows
        lastcolumn = Range("A19").End(xlToRight).Column  'This line get the total number of columns
        lastcolumn = lastcolumn + 1 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' FIX THIS LATER - ARRAY IS STOPPING 1 COLUMN SHORT
        ReDim Preserve myarray(1 To lastrow, 1 To lastcolumn)   'Define the size of array
        
    'Nested "For Loop" fills myarray with values from selected sheet
        For CountRow = 20 To lastrow
            For CountColumn = 1 To lastcolumn
                myarray(CountRow, CountColumn) = ActiveCell.Offset((CountRow - 1), (CountColumn - 1))
            Next CountColumn
        Next CountRow

For i = 20 To lastrow


                
        If myarray(i, Remedy) = "" Then  ' guessing this looks for FINAL remedy and if empty uses ENG remedy
            ActiveCell.Offset(1, 0).Value = myarray(i, Remedy - 1)
        Else
            ActiveCell.Offset(1, 0).Value = myarray(i, Remedy)
        End If
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I like helping here on the forum but I like users to tell me what their ultimate goal is.
I do not like trying to sort out scripts and determine what the user is trying to accomplish and then modify their script which does not work for them and try to fix it so it does work.

But then their are others here on the forum who do that.

Would you be so kind as to explain in specific detail what your ultimate goal is.
And I never use active cell in my scripts.
 
Upvote 0
I like helping here on the forum but I like users to tell me what their ultimate goal is.
I do not like trying to sort out scripts and determine what the user is trying to accomplish and then modify their script which does not work for them and try to fix it so it does work.

But then their are others here on the forum who do that.

Would you be so kind as to explain in specific detail what your ultimate goal is.
And I never use active cell in my scripts.

Hi thanks for the response!
1. I am inheriting this script from someone and am trying to fix the bugs so I thought I would work with Active Cell instead of rewriting the whole thing. The reason why active cell was used is because the output sheet is all relative. There could be some records that need 8 rows and some with only 6, etc. If there is a better substitute I would be welcome to hear it:)
2. The ultimate goal of the macro: the whole process is that Raw Data is placed in a "Make Ready" sheet which basically organizes the raw data into a certain format in order to be analyzed. From there, a thing called an Appsum (a separate macro, the one I am having problems with). Its goal is to organize that "Make Ready" data into what utility is responsible for each pole(record), and gives further analysis on if a pole attachment like for Cable, Phone, Fiber, need to be raised or lowered.

Hopefully this helps and if you want more info I can do that!
 
Upvote 0
Thanks for that explanation.
What I was looking for was something like this.

All my data is in column A and if a value in column A equals "Alpha" then
copy this row of data to a sheet named "Alpha"

Or something like that.

See I need to know where on your sheet the data is and what do we want to do with this data.

You said:
Its goal is to organize that "Make Ready" data into what utility is responsible for each pole(record), and gives further analysis on if a pole attachment like for Cable, Phone, Fiber, need to be raised or lowered.

1. Organize it how?
And things like that
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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