Greetings Experts,
I'm trying to look at the value of a cell in a range. In this case, the range is range("AK2", range("AK" & myLastRow)
If the cell contains "L" input =IF(AL2=AJ2,TRUE, FALSE)) - 3 cells down (in "AN2")
if the cell contains "KG" input =IFERROR(IF(OR(AJ2<am2*0.95,aj2>AM2*1.05),""Outside Limits"",""Within Limits""),""Error"") - 3 cells down (in "AN2")
I have never actually written a looping code before because I can't seem to get my ranges on point and I over think it creating variables for every single range... .. I've been using the examples/solutions I've received off of this forum previously, but I'm continually getting 1004 object-defined error.
I obviously did something wrong, but it looks pretty good to me. Any ideas? What am I not taking into account?
Thank you gents.</am2*0.95,aj2></am2*0.95,aj2>
I'm trying to look at the value of a cell in a range. In this case, the range is range("AK2", range("AK" & myLastRow)
If the cell contains "L" input =IF(AL2=AJ2,TRUE, FALSE)) - 3 cells down (in "AN2")
if the cell contains "KG" input =IFERROR(IF(OR(AJ2<am2*0.95,aj2>AM2*1.05),""Outside Limits"",""Within Limits""),""Error"") - 3 cells down (in "AN2")
I have never actually written a looping code before because I can't seem to get my ranges on point and I over think it creating variables for every single range... .. I've been using the examples/solutions I've received off of this forum previously, but I'm continually getting 1004 object-defined error.
I obviously did something wrong, but it looks pretty good to me. Any ideas? What am I not taking into account?
Code:
Sub weights()
Dim myWorksheet As Worksheet
Dim myLastrow As Long
Dim mycell As Range
Set myWorksheet = Worksheets("HazShipper")
myLastrow = myWorksheet.Cells(myWorksheet.Rows.Count, "A").End(xlUp).row
For Each mycell In Range("AK2", Range("AK" & myLastrow))
If mycell.Value = "L" Then mycell.Offset(, 3).[COLOR=#ff0000]Formula [/COLOR]= "=IF(AL2=AJ2,TRUE, FALSE))"
If mycell.Value = "KG" Then mycell.Offset(, 3).[COLOR=#ff0000]Formula [/COLOR]= "=IFERROR(IF(OR(AJ2<am2*0.95,aj2>AM2*1.05),""Outside Limits"",""Within Limits""),""Error"")"
Next mycell
End Sub
Thank you gents.</am2*0.95,aj2></am2*0.95,aj2>
Last edited: