in Education by
I want to using sumifs function in VBA. And result paste in same column as previous data. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Twice a SUMIF with Overwrite Workbook Download (Dropbox) Couldn't find any indication of SUMIFS, so I did it as if there is twice a SUMIF: For Columns A and C, and for Columns B and D. Option Explicit Sub SumUnique(UniqueFirstCell As Range, ValueFirstCell As Range) Dim rng As Range ' Unique Last Used Cell Dim dict As Object ' Dictionary Dim key As Variant ' Dictionary Key Counter (For Each Control Variable) Dim vntU As Variant ' Unique Range Array Dim vntV As Variant ' Value Range Array Dim vntUT As Variant ' Unique Array Dim vntVT As Variant ' Value Array Dim curV As Variant ' Current Value Dim NorS As Long ' Source Number of Rows Dim NorT As Long ' Target Number of Rows Dim i As Long ' Source/Target Row Counter ' Copy Unique Range to Unique Range Array. With UniqueFirstCell Set rng = .Worksheet.Columns(.Column) _ .Find("*", , xlFormulas, , , xlPrevious) Set rng = .Resize(rng.Row - .Row + 1) End With vntU = rng ' Copy Value Range to Value Range Array. With ValueFirstCell Set rng = .Worksheet.Columns(.Column) _ .Find("*", , xlFormulas, , , xlPrevious) Set rng = .Resize(rng.Row - .Row + 1) End With vntV = rng ' Create Unique Values and SumIf Values in Dictionary. Set dict = CreateObject("Scripting.Dictionary") NorS = UBound(vntU) For i = 1 To NorS curV = vntU(i, 1) If curV <> "" Then dict(curV) = dict(curV) + vntV(i, 1) End If Next NorT = dict.Count ' Resize Unique and Value Arrays to Target Number of Rows. ReDim vntUT(1 To NorT, 1 To 1) ReDim vntVT(1 To NorT, 1 To 1) i = 0 For Each key In dict.keys i = i + 1 ' Write Dictionary Keys to Unique Array. vntUT(i, 1) = key ' Write Dictionary Values to Value Array. vntVT(i, 1) = dict(key) Next ' Copy Unique Array to Target Unique Range. With UniqueFirstCell Set rng = .Resize(.Worksheet.Rows.Count - .Row + 1) rng.ClearContents Set rng = .Resize(NorT) End With rng = vntUT ' Copy Value Array to Target Value Range. With ValueFirstCell Set rng = .Resize(.Worksheet.Rows.Count - .Row + 1) rng.ClearContents Set rng = .Resize(NorT) End With rng = vntVT End Sub Sub Uni() Uni1 Uni2 End Sub Sub Uni1() Const cUni As String = "A2" Const cVal As String = "C2" With ThisWorkbook.Worksheets("Sheet1") SumUnique .Range(cUni), .Range(cVal) End With End Sub Sub Uni2() Const cUni As String = "B2" Const cVal As String = "D2" With ThisWorkbook.Worksheets("Sheet1") SumUnique .Range(cUni), .Range(cVal) End With End Sub I created two command buttons and put the following code into the sheet module: Option Explicit Private Sub cmdRevert_Click() [A2:D31] = [J2:M31].Value End Sub Private Sub cmdUnique_Click() Uni End Sub

Related questions

0 votes
    I have a master spreadsheet that analyzes records from another spreadsheet with rows going all the way up to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I am setting up a VBA userform function for my work that shows available quantities left to order based on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Below, I have code that sends a personalized SMS message and includes the name. I got that part to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Below, I have code that sends a personalized SMS message and includes the name. I got that part to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I'm using excel vba to pull data from a MS Access DB - this is using Excel 2013 and Access 2013 ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    ii) to find the largest value within the cell range starting from row 1 column A to row 25 column B [1+1] Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    I am trying to retrieve a particular file from multiple FTP servers. those server details are stored in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I am very new to VB and am exploring this method to simplify mundane manual work process of highlighting ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Could anyone recommend to me a good online guide to PowerPoint VBA? Also, does anyone has advice on how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    Could anyone recommend to me a good online guide to PowerPoint VBA? Also, does anyone has advice on how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I'm working on Excel VBA macros and I want to retrieve data from a MS Access database (.accdb ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I am new to VBA and I'm trying to create a form in Access where a text box is enabled or ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    As you can see from the code below i m looping an array and if condition met i want to get the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to adjust the row height based on the cell value. The operation have to run through ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have set up a new, empty, modeless userform, to fix my problem with the least amount of code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
...