Uncomfortable? If you mean that it's getting nowhere, then you're right. I don't see anything else wrong with it.
I suspect that Ayaz is not comfortable in English and also not familiar with asking technical questions. As such, this discussion isn't getting anywhere fast. :-)
I'll have a go at stating the part of the problem I think I'm starting to understand.
Regards, Dave S
----- Original Message -----Sent: Sunday, December 07, 2014 11:57 PMSubject: Re: [ExcelVBA] Help required for a difficult macroIs anybody else uncomfortable with this thread ?
From: "ayaz khan ayazthegreat2001@yahoo.com [ExcelVBA]" <ExcelVBA@yahoogroups.com>
To: ExcelVBA@yahoogroups.com
Sent: Sunday, 7 December 2014, 12:15
Subject: Re: [ExcelVBA] Help required for a difficult macro
Seems to be too difficult to be answered
From:"ayaz khan ayazthegreat2001@yahoo.com [ExcelVBA]" <ExcelVBA@yahoogroups.com>
Date:Sun, 7 Dec, 2014 at 1:23 PM
Subject:Re: [ExcelVBA] Help required for a difficult macromore explanation there are total 13 qty against ID A11 having different EDI # in sheet1 but result is demanding 4 qty against ID A11 so we distribute data like below
ID DI# EDI # Qty A11 - A1245 2 A11 - A1345 1 A11 - A1545 1 On Sunday, December 7, 2014 7:46 AM, "ayaz khan ayazthegreat2001@yahoo.com [ExcelVBA]" <ExcelVBA@yahoogroups.com> wrote:
thanks to replay but result is not as per my requirementOn Sunday, December 7, 2014 2:02 AM, "'Tim Lewis' twlewis@reagan.com [ExcelVBA]" <ExcelVBA@yahoogroups.com> wrote:
Ayaz, can you see if this is what you are looking for?Option ExplicitSub Get_Quantity()' This subroutine will go through the list of items in the Result Sheet' It will find items that do not have a quantity and get the quantity from Sheet1' If the quantity in DI# does not match the quantity in Qty it will mark the cell in red'''Assign the sheet names to a variable so that if the sheet names change, it will only have to be' changed once in the code.Dim ResultsSheet As String, SearchSheet As StringResultsSheet = "Result Sheet"SearchSheet = "Sheet1"'Variable UsedDim ResultsRowCount As Single, SearchRowCount As Single, ResultsSheetTotalRowCount As Single, _SearchSheetTotalRowCount As Single, DIValue As SingleDim strResultsEDINumber As String, strResultsDINumber As String, strResultsQty As StringDim strSearchEDINumber As String, strSearchQty As StringDim strResultsCurrentRow As String, strSearchCurrentRow As StringResultsSheetTotalRowCount = Sheets(ResultsSheet).UsedRange.Rows.CountSearchSheetTotalRowCount = Sheets(SearchSheet).UsedRange.Rows.CountFor ResultsRowCount = 2 To ResultsSheetTotalRowCount'Convert the counter to a stringstrResultsCurrentRow = LTrim(Str(ResultsRowCount))strResultsDINumber = Sheets(ResultsSheet).Range("B" strResultsCurrentRow).FormulaR1C1strResultsEDINumber = Sheets(ResultsSheet).Range("C" strResultsCurrentRow).FormulaR1C1strResultsQty = Sheets(ResultsSheet).Range("D" strResultsCurrentRow).FormulaR1C1'Get the numeric value of the DI entry. This is done to skip any that have a numeric valueDIValue = Val(strResultsDINumber)If DIValue = 0 ThenFor SearchRowCount = 2 To SearchSheetTotalRowCountstrSearchCurrentRow = LTrim(Str(SearchRowCount))strSearchEDINumber = Sheets(SearchSheet).Range("B" strSearchCurrentRow).FormulaR1C1strSearchQty = Sheets(SearchSheet).Range("C" strSearchCurrentRow).FormulaR1C1If strResultsEDINumber = strSearchEDINumber ThenSheets(ResultsSheet).Range("B" strResultsCurrentRow).FormulaR1C1 = strSearchQty'Exit the For loop because there is no need to continue after the entry is foundEnd IfNextEnd If'Get the current DI value because it may have changedstrResultsDINumber = Sheets(ResultsSheet).Range("B" strResultsCurrentRow).FormulaR1C1'If the DI value MATCHES the quantity then do NOT color the cell.If strResultsDINumber = strResultsQty ThenSheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.Pattern = xlNoneSheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.TintAndShade = 0Sheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.PatternTintAndShade = 0Else' If the DI does NOT MATCH the quantity then color the cell red.Sheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.Pattern = xlSolidSheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.PatternColorIndex = xlAutomaticSheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.Color = 255Sheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.TintAndShade = 0Sheets(ResultsSheet).Range("B" strResultsCurrentRow).Interior.PatternTintAndShade = 0End IfNextEnd SubTimFrom: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com]
Sent: Friday, December 05, 2014 11:36 PM
To: ExcelVBA@yahoogroups.com
Subject: Re: [ExcelVBA] Help required for a difficult macroDave thanks for your reply , but let me explain you more about this data, actually sheet1 is source data which is distributing/copying data in result sheet as per given Qty of result sheet in col D like as you mentioned that ("(1) A1545 has quantity 10 in Sheet 1, but only 1 in the result sheet.") this is because in result sheet the Qty in D col requirement is 1 and this is logic i want to communicate.(2) B6789 has one entry in Sheet 1) sorry it is wrong entry.Sir, i can explain you more in case of any confusion.
Sheet1 ID EDI # Qty A11 A1245 2 A11 A1345 1 A11 A1545 10 A16 B4567 3 A16 B6789 30
Result Sheet ID DI# EDI # Qty A11 - A1245 2 A11 - A1345 1 A11 - A1545 1 A12 2345 1 A13 3245 1 A16 - B4567 3 A16 - B6789 2 On Saturday, December 6, 2014 4:05 AM, "'David Smart' smartware.consulting@gmail.com [ExcelVBA]" <ExcelVBA@yahoogroups.com> wrote:Sorry, I can't see how you go from your Sheet1 to your result sheet.(1) A1545 has quantity 10 in Sheet 1, but only 1 in the result sheet.(2) B6789 has one entry in Sheet 1, but two entries in the result sheet. Also, however, the quantity 30 has become quantity 2 and quantity 1 - what about the other 27?Please explain how Sheet 1 transforms into the entries in the result sheet, with particular emphasis on the ones that don't have the same quantity, and on the ones that have more than one entry in the result sheet.
Regards, Dave S
----- Original Message -----Sent: Saturday, December 06, 2014 6:44 AMSubject: [ExcelVBA] Help required for a difficult macroI need a macro for my result sheet , let me explain you that i have sheet1 and there are 3 fields from col a to c and i need a macro for result sheet which matches ID number from result sheet col a (where DI# is blank in col b) with sheet1 col a and copy/distribute b col value from sheet1 to result sheet in col c which must be equal d col value , ok please see below example in red highlighted font cells as a macro result.
Sheet1 ID EDI # Qty A11 A1245 2 A11 A1345 1 A11 A1545 10 A16 B4567 3 A16 B6789 30
Result Sheet ID DI# EDI # Qty A11 - A1245 2 A11 - A1345 1 A11 - A1545 1 A12 2345 1 A13 3245 1 A16 - B4567 3 A16 - B6789 2 A16 - B6789 1No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5577 / Virus Database: 4235/8682 - Release Date: 12/04/14No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5577 / Virus Database: 4235/8693 - Release Date: 12/06/14
__._,_.___
Posted by: "David Smart" <smartware.consulting@gmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (11) |
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
.
__,_._,___
Tidak ada komentar:
Posting Komentar