dear friends i want to update my first sheet from second sheet.second sheet our packing report & it's daily I'm getting from packing department.according to packing report i want to update production sheet.second sheet Column "F" first 6 characters i need to mach with first sheet column "K" first 6 characters.if it is match then first sheet column "J" values need to reduce form second sheet column "G".
ex- first sheet value = 60
packing report value = 50 then answer in first sheet column "J" =60-50 = 10
after updating first sheet column "J" any value coming mines then that row need to delete.
pls make macro for this.thanks..
Last edited by johncena; 03-22-2010 at 05:34 AM.
This should do it:
Code:Option Explicit Sub PackingToProductionUpdate() Dim LotFind As Range, Lots As Range, LotNum As Range Application.ScreenUpdating = False Set Lots = Sheets("Packing").Range("F5", Range("F" & Rows.Count).End(xlUp)) On Error Resume Next For Each LotNum In Lots With Sheets("Production") Set LotFind = .Columns("K:K").Find(Left(LotNum, 6), After:=.Range("K" & Rows.Count), LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) If Not LotFind Is Nothing Then LotFind.Offset(0, -1).Value = LotFind.Offset(0, -1).Value - LotNum.Offset(0, 1).Value LotNum.EntireRow.ClearContents Set LotFind = Nothing End If End With Next LotNum Application.ScreenUpdating = True End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
This might be what you need.
Code:Sub Process() For N = 5 To Sheets("PACKING").Cells(Rows.Count, 1).End(xlUp).Row If Application.CountIf(Sheets("PRODUCTION").Columns(11), Left(Sheets("PACKING").Cells(N, 6), 6)) = 1 Then Set TargetCell = Sheets("PRODUCTION").Columns(11).Find(Left(Sheets("PACKING").Cells(N, 6), 6), , xlValues, xlPart) TargetCell.Offset(0, -1) = TargetCell.Offset(0, -1) - Sheets("PACKING").Cells(N, 7) If TargetCell.Offset(0, -1) < 0 Then TargetCell.EntireRow.Delete End If Next N End Sub
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
dear JB thanks u very much for your helps.i have two problems.one is below code giving some error.other one is both sheet values are equals then first sheet that row also need to delete.i mean after minus first reports values from second sheet values answers are zero or minus then that all rows should delete,
Code:Set Lots = Sheets("Packing").Range("F5", Range("F" & Rows.Count).End(xlUp))
Last edited by johncena; 03-21-2010 at 01:33 AM.
dear mrice.your macro matching all cell values.not first 6 characters.if second sheet column "F" value = 126546D & first sheet Column "K" value = 126546A-D then your macro not working.& other thing is some values u reducing form first sheet column "K" that values can i see,i mean not final answer.if i click that cell it should below example.
ex- =150-50
Here's the update to delete the PRODUCTION row if the value drops to zero or below:
Code:Option Explicit Sub PackingToProductionUpdate() Dim LotFind As Range, Lots As Range, LotNum As Range Dim LotVal As Double Application.ScreenUpdating = False Set Lots = Sheets("Packing").Range("F5", Range("F" & Rows.Count).End(xlUp)) On Error Resume Next For Each LotNum In Lots With Sheets("Production") Set LotFind = .Columns("K:K").Find(Left(LotNum, 6), After:=.Range("K" & Rows.Count), LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) If Not LotFind Is Nothing Then LotVal = LotFind.Offset(0, -1).Value - LotNum.Offset(0, 1).Value If LotVal <= 0 Then LotFind.EntireRow.Delete xlShiftUp Else LotFind.Offset(0, -1).Value = LotVal End If LotNum.EntireRow.ClearContents Set LotFind = Nothing End If End With Next LotNum Application.ScreenUpdating = True End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
dear JB everything work very well.just one adjustment i need.some values u reducing form first sheet column "K" that values can i see,i mean not final answer.if i click that cell it should below example.then i can understand how much packed & how much balance to pack.
ex- =4500-500
Last edited by johncena; 03-21-2010 at 04:45 AM.
Um.........huh?
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
sorry JB if it is not possible then leave it.no problem.u help me a lot.if u can do it.it's very help full for me..
If I can do what?
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
JB.I'm talking about # 7 post request.
My reply to your post #7 is summed up in post #8.![]()
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
thanks for your all helps JB.now everything work very well,i have replace this macro code with..
this..Code:LotFind.Offset(0, -1).Value = LotVal
thanks a lot again.REP+ add.Code:LotFind.Offset(0, -1).Value = "=" & LotFind.Offset(0, -1).Value & "-" & LotNum.Offset(0, 1).Value
Ah...the lights have got on. Now I see what you mean. Nice work, John!
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
JB again i need your help.my code doing some mistakes.if one time I'm reduced some values my code work very well.if i reduced more than one time my requirement not success.
ex-sheet one cell value =200
one time reduce =50
my code answer giving correct =200-50
if i reduce again =50
macro answer =150-50
it should =200-50-50
pls help me sir...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks