PDA

View Full Version : Check Column w Criteria



KarNeedsHelp
06-03-2011, 06:20 PM
Hi can someone help me with this macro that I want to do?
I want to write a macro that basically checks Column A and goes through each cell with value, and if it's not blank then Column B will say Y

We don't have a set range because it will vary from cases to cases.
So something that checks like the top cell offset by 1 because of the header to the last cell with value in that column.

so if A2=value B2=Y
it will keep doing that until the last cell with value.

slamet Harto
06-03-2011, 06:28 PM
Sub test()
Dim c As Range
For Each c In Selection
If c.Value <> "" Then
c.Offset(0, 1) = "Y"
End If
Next

End Sub

mikerickson
06-03-2011, 06:32 PM
Application.Intersect(Cells.SpecialCells(xlCellTypeConstants).EntireRow, Columns(2)).Value = "Y"

KarNeedsHelp
06-03-2011, 07:00 PM
Thanks, but I don't want it to overwrite the header which is in the first row for both column A and B.

GTO
06-03-2011, 08:54 PM
Using Mike's example: With Sheet1 '<---CodeName or Sheet Name---> ThisWorkbook.Worksheets ("Sheet1")
Application.Intersect(Range(.Range("A2"), .Cells(.Rows.Count, 1)).SpecialCells(xlCellTypeConstants).EntireRow, .Columns(2)).Value = "Y"
End With

mikerickson
06-03-2011, 10:20 PM
With Sheet1
Application.Intersect(.UsedRange.Offset(0,1).SpecialCells(xlCellTypeConstan ts).EntireRow, .Columns(2)).Value = "Y"
End If

KarNeedsHelp
06-04-2011, 02:57 PM
Thanks for the help everyone, the macro works now. I made some few changes to Mike's code, thanks for the help again.