Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2004, 06:20 AM
Authorized User
 
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reduce the stock when place order

Hello All

My problem is :
This code works fine, but when i place the ordered Qyt in the invoice sheet (E19.....E49),
the qyt should be reduced from the quantities range (D32:D1800) in the stock sheet..........

Ths problem, the reduction is placed one row below the row that contain the qyts ordered

i donot know why i tested the code line by line............but

pls, any help would be appreciated....

the code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OrdVal As Long
Dim strOrd As String
Dim lrow As Long
Dim rngStock As Range
Dim myCheck As Integer

On Error GoTo err
If Application.Intersect(Target, Range("C19:C49")) Is Nothing Then
    'Exit Sub
Else
    OrdVal = Target.Value
    strOrd = Target.Offset(0, 2).Value

myCheck = MsgBox("" & OrdVal & " Units of " & strOrd & " were ordered", vbYesNo)
    If myCheck = vbNo Then
    Exit Sub
    End If

    lrow = Application.Match(strOrd, Sheet3.Range("C1:C1800"), 0)
    Set rngStock = Sheet3.Range("C1").Offset(lrow, 1)
    rngStock.Value = rngStock.Value - OrdVal
End If
Set rngStock = Nothing
err: Exit Sub
End Sub



yours
hesham






Similar Threads
Thread Thread Starter Forum Replies Last Post
Stock feed hudeanee Excel VBA 1 July 24th, 2007 08:29 PM
stock management- closing stock and opening stock bright_mulenga Access 1 July 16th, 2007 07:11 AM
reduce viewstate size vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 May 10th, 2007 07:20 AM
How to reduce the processing time for this prob? changeable Excel VBA 0 October 27th, 2004 04:12 AM
Stock Quote JonnyRPI Classic ASP Basics 1 June 3rd, 2003 09:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.