how do I add the letter Y to column (U).
I need it to check if there is any data in the column to the left (column T), and if there is, Insert a Y in column U.
how do I add the letter Y to column (U).
I need it to check if there is any data in the column to the left (column T), and if there is, Insert a Y in column U.
Put this in U1 and drag-down:
![]()
=IF(T1<>"","Y","")
Oh! I get it.
I need rep--->҉
Thank you, but I need it in the VBA form.
I am getting closer. I now have this...
ws1.Range("A" & i & ":R" & i).Copy ws2.Rows(ws2.Cells(ws2.Rows.Count, 3).End(xlUp).Row + 1).Range("A1").Offset(RowOffset:=0, ColumnOffset:=1)
The ColumnOffset is now working.
The RowOffset is not. When I use RowOffset:=0, it still starts to paste on row 2 (I need it to start paste on row 3).
When I use RowOffset:=1, it starts to paste on line 3, but then skips every other row when pasting.
paste
skip row
paste
skip row
and so on.
Any ideas?
Here's a short straight-forward macro that does the task, I think.
Change the 1 in the FOR loop to whichever starting row you need.
![]()
Sub check_col_T_and_put_Y_in_col_U() Dim lastRow As Long Dim row As Long Application.ScreenUpdating = False lastRow = ActiveSheet.Cells(Rows.Count, "T").End(xlUp).Row For row = 1 To lastRow If Cells(row, "T") <> "" Then Cells(row, "U") = "Y" Next row Application.ScreenUpdating = True End Sub
Thx Stew, this works. But if I wanted to change 1 part of it, to look in column "L" for anything less than (<) 240.00, and if it finds it, put "Y" in column "U", how would it look. It is only finding some of them. All values in row L is 0.1 to 0.63 right now, but this can change.
For row = 2 To lastRow
If Cells(row, "L") < "240.00" Then Cells(row, "U") = "Y"
Next row
Remove the quotation marks around 240.00 so that the decision compares numbers not strings.
Hope this helps,![]()
For row = 2 To lastRow If Cells(row, "L").value < 240.00 Then Cells(row, "U") = "Y" Next row
- Stu
Stu, That worked.
Do you know the code for >72 and <240 in the same line?
This is the line I need to add >240 to....
![]()
If ws1.Cells(i, 4) = "A" And ws1.Cells(i, 12) > 72 And ws1.Cells(i, 14) = "Standard" Then
Last edited by Pat1009; 07-09-2015 at 06:34 PM.
Stu, That worked.
Do you know if there is VBA code to Change the cell color and font color to Red in Column "V" if column "M" is > 240.00?
_________________________________________________
Try something like this…
![]()
Sub check_Column_L() Dim lastRow As Long Dim row As Long Dim cellValue As Double lastRow = ActiveSheet.Cells(Rows.Count, "L").End(xlUp).row For row = 2 To lastRow cellValue = Cells(row, "L").Value If cellValue <= 240# Then Cells(row, "U") = "Y" Cells(row, "V").Font.Color = RGB(255, 0, 0) ' red Cells(row, "V").Interior.Color = RGB(150, 250, 50) ' lime green Else Cells(row, "U").ClearContents Cells(row, "V").Font.Color = RGB(0, 0, 0) ' black Cells(row, "V").Interior.Color = RGB(255, 255, 255) ' white End If Next row End Sub
Thx Stu! This is good
Hi Pat.
I just noticed that my sample code changed the cells in column V to red when the corresponding cell in column L was less than or equal to 240. You wanted greater than 240 and will need to adjust the decision and/or statements as you need. Will leave that exercise to you.
If this previous posts have been helpful, please click the 'Add Reputation' button.
- Stu
Yes,I saw that, thank you.
One last point - Color coding the cells can be accomplished with Conditional Formatting.
Using that would have the advantage of immediate results without having to run a macro.
- Some food for thought.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks