|
Transfer Values Based On Condition & Insert Date
Please Register to Remove these Ads
Any help to fix my code is appreciated.
So far it's not doing what I need it to.
For the item numbers in column A, I have a values representing quanities in columns D,E,G, and L. D&E being the most recent qty value.
If the value in column E changes and is not equal to value in G, than these values for the item number in A, will be copied and replacing the values in G. Likewise, G will be transfered to L.
For each change in value in G, I want to have the current date be put into column H for the corresponding row. For each transfer from G to L.
The date in column H will be copied to column M for the corresponding row.
I've attached an example problem.
The code so far is as follows:
Code:
Sub LoadSub()
'Sheets("Inventory_YARD").Activate
'Working_Yard
'LastRow = Cells(Rows.Count, 1).End(xlUp).Row
'For i = 1 To LastRow
' For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
'Application.StatusBar = "Transferring Inventory Counts & Updating Yard Count" & i & " of " & LastRow
'If Cells(i, "E") - Cells(i, "G") <> 0 Then
'TO COPY INVENTORY COUNTS OVER TO NEXT COLUMN AND TO UPDATE YARD COUNTS
' Set findit = OutPL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
'If Not findit Is Nothing Then
' Set findit = Sheets("Inventory_YARD").Range("A:A").Find(what:=Cells(i, 1).Value)
'Next i
'Set OutPL = Sheets("Inventory_YARD")
'Sheets("Inventory_YARD").Activate
'For J = OutPL.Cells(i, 1).End(xlUp).find:Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
'LastRow = Cells(Rows.Count, 1).End(xlUp).Row
'For i = 1 To LastRow
' Application.StatusBar = "Transferring Inventory Counts & Updating Yard Count" & i & " of " & LastRow
'Cells(i, "O").Value = findit.Offset(0, 24).Value
' Cells(i, "Q").Value = findit.Offset(0, 25).Value
' Set findit = Sheets("Inventory_YARD").Range("A:A").Find(what:=Cells(i, 1).Value)
' If Not findit Is Nothing Then
' If findit.Offset(i, 15) - findit.Offset(i, 11) <> 0 Then
' findit.Offset(i, 15).Value = findit.Offset(i, 11).Value
' findit.Offset(i, "16").Value = findit.Offset(i, "12").Value
' End If
'If Cells(i, "G") - Cells(i, "L") <> 0 Then
'If findit.Offset(i, "20") - findit.Offset(i, "18") <> 0 Then
' findit.Offset(i, 11).Value = findit.Offset(i, 6).Value
' Cells(i, "M").Value = findit.Offset(i, 7).Value
' End If
'If findit.Offset(i, "20") - findit.Offset(i, "18") <> 0 Then
' Cells(i, "E").Value = findit.Offset(i, "6").Value
' Cells(i, "F").Value = OutPL.Format(Now, "mm/dd/yyyy")
' End If
' End If
'Next i
'End If
'End If
'Next i
a = 1
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 8 To LastRow
Set Findit = Sheets("Inventory_YARD").Range("A:A").Find(what:=Cells(i, 1).Value)
If (Cells(i, 5).Value <> Cells(i, 7).Value) Then
'Set J=OutPL.Cells(i, 1).End(xlUp).find:Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Set OutPL = Sheets("Inventory_YARD")
a = a + 1
Findit.Cells(i, 5).Copy
Findit.Cells(a, 7).PasteSpecial Paste:=xlValues
'Cells(a, G).Value = OutPL.Format(Now, "mm/dd/yyyy")
'Cells(a, 7) = DATE:"MM,DD,YYYY")
End If
Next i
Application.StatusBar = False
MsgBox "Done"
End Sub
I've commented out a lot of lines, that I've tried to use to get something working for me.
To test, just put any value you want into columns E. Again, if the value is
different than the value appearing in column G, than the value in E should get transferred to G. Therefore, the sequece of events will be :
G to L
then
E to G
Again, Any help is appriciated.
Thanks,
BDB
|