Error in routing the values from one sheet to another
Dear All,
I couldn't able to guess the error in the code shown below
My Requirement is to route the quantity entered in Shet "Receipts UF" by selecting the Item & its dependent Model & particular date in which Inward of a particular model is done.
Attached the file for your reference.
PHP Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$E$9" Then
Dim item As Long, ws2 As Worksheet, ws1 As Worksheet, item2 As String, item3 As String
item3 = Sheets("Receipts UF").Range("E4").Value
Set ws2 = Sheets(item3)
If item3 = "Production" Then
r = Application.Index(ws2.Range("A1", "BK81"), Application.Match(item2, ws2.Range("A:A"), 0), Application.Match(item, ws2.Range("A1:BK1"), 0)).Address
End If
If item3 <> "Production" Then
r = Application.Index(ws2.Range("A1", "BK81"), Application.Match(item2, ws2.Range("A:A"), 0), Application.Match(item, ws2.Range("A1:BK1"), 0) + 1).Address
End If
ws2.Range(r).Value = ws2.Range(r).Value + ws1.Range("E8").Value
MsgBox ws1.Range("E8").Value & " pieces are added to " & ws1.Range("E4") & Chr(13) _
& Chr(13) & "Model " & ws1.Range("E6") & Chr(13) & Chr(13) & "On date " & ws1.Range("E2") & Chr(13) & Chr(13) & "Total is now " & ws2.Range(r)
End If
End Sub
Edit* After looking at you workbook I noticed there isn't an Item3 sheet so the sheet name is likely incorrect??
Last edited by gmr4evr1; 12-13-2015 at 10:54 AM.
Reason: Added Edit*
1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.
Re: Error in routing the values from one sheet to another
When I looked at your workbook the other day, there was no sheet named Item3.........Adding the quotes will do no good if there is no sheet named Item3, hence the ".....out of range error"
Removing the quotes gives you a "......mismatch" error because to call a sheet, it needs the quotes.
Bookmarks