leezac
asked on
Insert text when conditions are met
I need help with vba to do the following
If Number in column C of sheet4 matches sheet19 column A
and sheet4 column AQ = "file"
and column AP of Sheet4 is not null
then place "1" in column D of sheet19
to end of row of column A of sheet19
---------------
this is what I have so far
Dim lngRow As Long
Dim objCell As Range
Dim objRange As Range
On Error Resume Next
Application.ScreenUpdating = False
Set objRange = Range(Sheets("sheet4").[c3 ], Sheets("sheet4").Cells(She ets("Sheet 4").Cells. Rows.Count , "C").End(xlUp))
If Not (objRange Is Nothing) Then
Sheets("Missing 3PM Prices").Select
For lngRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row To 2& Step -1&
Set objCell = Nothing
Set objCell = objRange.Find(What:=Cells( lngRow, "A"))
If Not (objCell Is Nothing) Then
If Not (IsEmpty(Sheets("Sheet4"). Cells(objC ell.Row, "AP")))
Thanks in advance
If Number in column C of sheet4 matches sheet19 column A
and sheet4 column AQ = "file"
and column AP of Sheet4 is not null
then place "1" in column D of sheet19
to end of row of column A of sheet19
---------------
this is what I have so far
Dim lngRow As Long
Dim objCell As Range
Dim objRange As Range
On Error Resume Next
Application.ScreenUpdating
Set objRange = Range(Sheets("sheet4").[c3
If Not (objRange Is Nothing) Then
Sheets("Missing 3PM Prices").Select
For lngRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row To 2& Step -1&
Set objCell = Nothing
Set objCell = objRange.Find(What:=Cells(
If Not (objCell Is Nothing) Then
If Not (IsEmpty(Sheets("Sheet4").
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use this line
Sheets(sh2).cells(i, "D").value = 1
I thought you wanted from D to Last Column, no biggie.
Sheets(sh2).cells(i, "D").value = 1
I thought you wanted from D to Last Column, no biggie.
ASKER
Thanks
ASKER
I do not know how to change the line below
Sheets(sh2).Range("D" & ":D" & i).Value = 1
__________________________
Application.ScreenUpdating
Dim lngRow As Long, sh1 As String, sh2 As String
sh1 = "Compare"
sh2 = "tmp"
lngRow = Sheets(sh1).UsedRange.Rows
For i = lngRow To 2 Step -1
If Sheets(sh1).Cells(i, "C").Value = Sheets(sh2).Cells(i, "A").Value _
And Sheets(sh1).Cells(i, "AQ").Value = "file" _
And Sheets(sh1).Cells(i, "AP").Value <> "" Then
Sheets(sh2).Range("D" & ":D" & i).Value = 1
End If
Next