Require VBA Code

loknathmondal

New Member
Joined
Sep 1, 2015
Messages
31
There are 4 excel sheets in a workbook and every sheet has huge data i.e.
datewise productwise sales details


Now i want get the below details in 5th excel sheet i.e. total sales of
specific product in specific time by using VBA code as every sheet has atleast
4-5 lakhs data



Why i'm asking this as i have to select specific product then specific priod of
each excel sheet and paste it to new excel sheet, it took 30-45 minutes.

Example Below:

ProductsVolumeTransaction Date
Mango7617-10-17
Apple13019-10-17
Orange1221-10-17
Banana11023-10-17
Guava13725-10-17
Cherry11727-10-17
Sweet12529-10-17
Papiya4531-10-17
Litchi12402-11-17
Jack Fruit6604-11-17
Lemon10506-11-17
Ginger5408-11-17
Garlic3010-11-17
Cumin6912-11-17
Mango14014-11-17
Apple2916-11-17
Orange11818-11-17
Banana9520-11-17
Guava4722-11-17
Cherry12624-11-17
Sweet11226-11-17
Papiya3528-11-17
Litchi1730-11-17
Jack Fruit8202-12-17
Lemon8104-12-17
Ginger1006-12-17
Garlic9308-12-17
Cumin3510-12-17
Mango7512-12-17
Apple6414-12-17
Orange8816-12-17
Banana13518-12-17
Guava3520-12-17
Cherry8422-12-17
Sweet10424-12-17
Papiya7226-12-17
Litchi4328-12-17
Jack Fruit3930-12-17
Lemon6801-01-18
Ginger8503-01-18
Garlic6605-01-18
Cumin13507-01-18
Mango5309-01-18
Apple3211-01-18
Orange7013-01-18
Banana1215-01-18
Guava13017-01-18
Cherry12719-01-18
Sweet7821-01-18
Papiya5223-01-18
Litchi14325-01-18
Jack Fruit13227-01-18
Lemon9329-01-18
Ginger8731-01-18
Garlic3102-02-18
Cumin6804-02-18
Mango9406-02-18
Apple11108-02-18
Orange9410-02-18
Banana2012-02-18
Guava6314-02-18
Cherry4516-02-18
Sweet1418-02-18
Papiya12120-02-18
Litchi12922-02-18
Jack Fruit3524-02-18
Lemon2926-02-18
Ginger1828-02-18
Garlic13202-03-18
Cumin9304-03-18
Mango5106-03-18
Apple12208-03-18
Orange6410-03-18
Banana14112-03-18
Guava4914-03-18
Cherry4316-03-18
Sweet8218-03-18
Papiya5920-03-18
Litchi8322-03-18
Jack Fruit14024-03-18
Lemon2526-03-18
Ginger3028-03-18
Garlic6530-03-18
Cumin9101-04-18
Mango10903-04-18
Apple6805-04-18
Orange3607-04-18
Banana14809-04-18
Guava5711-04-18
Cherry1413-04-18
Sweet8215-04-18
Papiya11017-04-18
Litchi13319-04-18
Jack Fruit8021-04-18
Lemon5123-04-18
Ginger1225-04-18
Garlic3627-04-18
Cumin2529-04-18
Mango11101-05-18
Apple4103-05-18
Orange6605-05-18
Banana5107-05-18
Guava4509-05-18
Cherry8411-05-18
Sweet9513-05-18
Papiya10515-05-18
Litchi1717-05-18
Jack Fruit14119-05-18
Lemon5221-05-18
Ginger3023-05-18
Garlic5225-05-18
Cumin10527-05-18
Mango12329-05-18
Apple10831-05-18
Orange13402-06-18
Banana12604-06-18
Guava12806-06-18
Cherry11008-06-18
Sweet7210-06-18
Papiya7112-06-18
Litchi2414-06-18
Jack Fruit1816-06-18
Lemon4518-06-18
Ginger10920-06-18
Garlic2022-06-18
Cumin5424-06-18
Mango6026-06-18
Apple14528-06-18
Orange12530-06-18
Banana5202-07-18
Guava14104-07-18
Cherry14406-07-18
Sweet2408-07-18
Papiya9610-07-18
Litchi3412-07-18
Jack Fruit8414-07-18
Lemon4816-07-18
Ginger10518-07-18
Garlic4220-07-18
Cumin7122-07-18
Mango1217-10-17
Apple5819-10-17
Orange11721-10-17
Banana1323-10-17
Guava11125-10-17
Cherry7127-10-17
Sweet1629-10-17
Papiya1431-10-17
Litchi14202-11-17
Jack Fruit14204-11-17
Lemon4306-11-17
Ginger9608-11-17
Garlic6710-11-17
Cumin10312-11-17
Mango2914-11-17
Apple4916-11-17
Orange7318-11-17
Banana9320-11-17
Guava3522-11-17
Cherry12724-11-17
Sweet11926-11-17
Papiya7328-11-17
Litchi7730-11-17
Jack Fruit13902-12-17
Lemon12604-12-17
Ginger5306-12-17
Garlic1908-12-17
Cumin9810-12-17
Mango4412-12-17
Apple8614-12-17
Orange4616-12-17
Banana9918-12-17
Guava14220-12-17
Cherry6422-12-17
Sweet7124-12-17
Papiya13026-12-17
Litchi5628-12-17
Jack Fruit10330-12-17
Lemon12201-01-18
Ginger2903-01-18
Garlic1105-01-18
Cumin5607-01-18
Mango12009-01-18
Apple3511-01-18
Orange13813-01-18
Banana1915-01-18
Guava8917-01-18
Cherry13419-01-18
Sweet11021-01-18
Papiya2723-01-18
Litchi2525-01-18
Jack Fruit13227-01-18
Lemon13729-01-18
Ginger12831-01-18
Garlic6002-02-18
Cumin13104-02-18
Mango12106-02-18
Apple12208-02-18
Orange13610-02-18
Banana12312-02-18
Guava13514-02-18
Cherry8916-02-18
Sweet13518-02-18
Papiya11520-02-18
Litchi11922-02-18
Jack Fruit14724-02-18
Lemon1826-02-18
Ginger8328-02-18
Garlic4002-03-18
Cumin12404-03-18
Mango10406-03-18
Apple2408-03-18
Orange3510-03-18
Banana12612-03-18
Guava6814-03-18
Cherry6316-03-18
Sweet7618-03-18
Papiya5820-03-18
Litchi12922-03-18
Jack Fruit8124-03-18
Lemon9326-03-18
Ginger10328-03-18
Garlic15030-03-18
Cumin10401-04-18
Mango1903-04-18
Apple7205-04-18
Orange11607-04-18
Banana8509-04-18
Guava6311-04-18
Cherry7413-04-18
Sweet4615-04-18
Papiya10317-04-18
Litchi12419-04-18
Jack Fruit1021-04-18
Lemon8723-04-18
Ginger3325-04-18
Garlic9127-04-18
Cumin12329-04-18
Mango8401-05-18
Apple7703-05-18
Orange1605-05-18
Banana10507-05-18
Guava6409-05-18
Cherry5011-05-18
Sweet4813-05-18
Papiya6615-05-18
Litchi4817-05-18
Jack Fruit7219-05-18
Lemon14721-05-18
Ginger14623-05-18
Garlic1125-05-18
Cumin11527-05-18
Mango9029-05-18
Apple12931-05-18
Orange1902-06-18
Banana7004-06-18
Guava10706-06-18
Cherry12008-06-18
Sweet2210-06-18
Papiya12812-06-18
Litchi7014-06-18
Jack Fruit2016-06-18
Lemon3518-06-18
Ginger13120-06-18
Garlic3222-06-18
Cumin2724-06-18
Mango4326-06-18
Apple1428-06-18
Orange10830-06-18
Banana7602-07-18
Guava6304-07-18
Cherry10406-07-18
Sweet4908-07-18
Papiya8810-07-18
Litchi2912-07-18
Jack Fruit7614-07-18
Lemon13116-07-18
Ginger13518-07-18
Garlic9820-07-18
Cumin6322-07-18

<colgroup><col><col><col></colgroup><tbody>
</tbody>



Regards
Loknath
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
1. I think you are using the wrong tool....you want ms Access.
2. Have you tried using pivot tables in excel?
 
Upvote 0
Had to look up definition of
lakhs
.
Says
lakhs
means hundred thousand.

So if you have 4-5
lakhs
rows of data on 4 sheets and you want to do evaluation on all this data.
This is beyond my knowledgebase.
I will continue to monitor this thread to see what I can learn.
 
Upvote 0
Hint: Best to keep sample data smaller than what you provided.

Assuming ..
- The data like you have shown is in columns A:C of each sheet with headings in row 1
- The dates are real dates (numbers) not text
- You can set up the 5th sheet, called "Summary" like below, entering your criteria in range A2:C2. (The name & layout could be different but the code would need to be adjusted to match)


Book1
ABCD
1ProductStart DateEnd DateVolume
2Mango1-10-201731-03-2018
Summary


Then try running this macro
Code:
Sub TotalSales()
  Dim ws As Worksheet
  Dim sProd As String
  Dim dStart As Date, dEnd As Date
  Dim a As Variant
  Dim i As Long
  Dim TotSales As Double
  
  With Sheets("Summary")
    sProd = LCase(.Range("A2").Value)
    dStart = .Range("B2").Value
    dEnd = .Range("C2").Value
  End With
  For Each ws In Worksheets
    If ws.Name <> "Summary" Then
    a = ws.Range("A1", ws.Range("C" & ws.Rows.Count).End(xlUp)).Value
    For i = 2 To UBound(a)
      If LCase(a(i, 1)) = sProd Then
        If a(i, 3) >= dStart Then
          If a(i, 3) <= dEnd Then TotSales = TotSales + a(i, 2)
        End If
      End If
    Next i
    End If
  Next ws
  Sheets("Summary").Range("D2").Value = TotSales
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top