VBA Smaller Code 5

ziad alsayed

Well-known Member
Joined
Jul 17, 2010
Messages
665
dear all

the below code is working perfectly, i just need to reduce it.

appreciate any help


Code:
Sub MoveSalesToSheets()
Dim wbo As Workbook
Set wbo = ActiveWorkbook
Set wsd = wbo.Worksheets("Data")
Set wsphc = wbo.Worksheets("PHC")
Set wsapapa = wbo.Worksheets("Apapa")
Set wsvi = wbo.Worksheets("VI")
Set wskano = wbo.Worksheets("Kano")
Set wsikeja = wbo.Worksheets("Ikeja")
wsphc.Select
If Cells(2, 1) = "Jan" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(4, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(4, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(4, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(4, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(4, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(4, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
        Range(Cells(4, 2), Cells(15, 2)).Select
        With Selection
        .Value = .Value
        End With
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(4, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(4, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(4, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(4, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(4, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(4, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(4, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(4, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(4, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(4, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(4, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(4, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(4, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(4, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(4, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(4, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(4, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(4, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(4, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(4, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(4, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(4, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
'wsphc.Select
ElseIf Cells(2, 1) = "Feb" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(5, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(5, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(5, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(5, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(5, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(5, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(5, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(5, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(5, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(5, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(5, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(5, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(5, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(5, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(5, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(5, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(5, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(5, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(5, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(5, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(5, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(5, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(5, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(5, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(5, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(5, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(5, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(5, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Mar" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(6, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(6, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(6, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(6, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(6, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(6, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(6, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(6, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(6, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(6, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(6, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(6, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(6, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(6, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(6, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(6, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(6, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(6, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(6, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(6, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(6, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(6, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(6, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(6, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(6, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(6, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(6, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(6, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Apr" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(7, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(7, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(7, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(7, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(7, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(7, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(7, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(7, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(7, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(7, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(7, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(7, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(7, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(7, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(7, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(7, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(7, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(7, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(7, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(7, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(7, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(7, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(7, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(7, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(7, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(7, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(7, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(7, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "May" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(8, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(8, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(8, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(8, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(8, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(8, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(8, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(8, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(8, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(8, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(8, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(8, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(8, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(8, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(8, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(8, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(8, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(8, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(8, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(8, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(8, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(8, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(8, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(8, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(8, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(8, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(8, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(8, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Jun" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(9, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(9, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(9, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(9, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(9, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(9, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(9, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(9, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(9, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(9, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(9, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(9, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(9, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(9, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(9, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(9, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(9, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(9, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(9, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(9, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(9, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(9, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(9, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(9, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(9, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(9, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(9, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(9, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Jul" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(10, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(10, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(10, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(10, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(10, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(10, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(10, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(10, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(10, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(10, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(10, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(10, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(10, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(10, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(10, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(10, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(10, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(10, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(10, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(10, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(10, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(10, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(10, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(10, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(10, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(10, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(10, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(10, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Aug" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(11, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(11, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(11, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(11, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(11, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(11, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(11, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(11, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(11, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(11, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(11, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(11, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(11, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(11, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(11, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(11, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(11, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(11, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(11, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(11, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(11, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(11, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(11, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(11, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(11, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(11, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(11, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(11, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Sep" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(12, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(12, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(12, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(12, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(12, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(12, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(12, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(12, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(12, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(12, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(12, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(12, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(12, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(12, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(12, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(12, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(12, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(12, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(12, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(12, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(12, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(12, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(12, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(12, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(12, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(12, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(12, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(12, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Oct" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(13, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(13, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(13, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(13, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(13, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(13, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(13, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(13, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(13, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(13, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(13, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(13, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(13, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(13, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(13, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(13, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(13, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(13, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(13, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(13, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(13, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(13, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(13, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(13, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(13, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(13, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(13, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(13, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Nov" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(14, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(14, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(14, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(14, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(14, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(14, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(14, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(14, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(14, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(14, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(14, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(14, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(14, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(14, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(14, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(14, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(14, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(14, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(14, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(14, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(14, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(14, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(14, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(14, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(14, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(14, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(14, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(14, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
        
ElseIf Cells(2, 1) = "Dec" Then
'Add Data to PHC Sheet
    ' select PHC Sheet
        wsphc.Select
    ' sheet PHC, Solomon sales
        Cells(15, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
    ' sheet PHC, Emeka sales
        Cells(15, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
    ' sheet PHC, Innocent sales
        Cells(15, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
    ' sheet PHC, Doris sales
        Cells(15, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
    ' sheet PHC, Spencer sales
        Cells(15, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
    'sheet PHC Johnnie sales
        Cells(15, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
     
'add data to Apapa sheet
        wsapapa.Select
    'sheet Apapa Blessing sales
        Cells(15, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
    ' sheet Apapa Angela Sales
        Cells(15, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
    'sheet Apapa Helen Sales
        Cells(15, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
    'sheet Apapa Patrick Sales
        Cells(15, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
    'sheet apapa Wesley Sales
        Cells(15, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
    ' sheet Apapa Linda Sales
        Cells(15, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
       
'add data to VI sheet
        wsvi.Select
    'sheet VI haytham sales
        Cells(15, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
    ' sheet VI Osaratin Sales
        Cells(15, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
    'sheet VI Romoke Sales
        Cells(15, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
    'sheet VI Dorothy Sales
        Cells(15, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
    'sheet VI Jhon Sales
        Cells(15, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
       
'add data to Kano Sheet
        wskano.Select
    'sheet Kano Abdulkadir sales
        Cells(15, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
    ' sheet Kano Sani Nasiru Sales
        Cells(15, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
    'sheet Kano Sani Adamu Sales
        Cells(15, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
    'sheet Kano Zahra Sales
        Cells(15, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
      
' add Data to Ikeja Sheet
       wsikeja.Select
    ' sheet Ikeja, Jide  sales
        Cells(15, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
    ' sheet Ikeja, Margaret sales
        Cells(15, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
    ' sheet Ikeja, Folake sales
        Cells(15, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
    ' sheet Ikeja, Sabitu sales
        Cells(15, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
    ' sheet Ikeja, Olawaseum sales
        Cells(15, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
    'sheet Ikeja, Mohammed Khobaiz sales
        Cells(15, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
    'sheet Ikeja Patrick Sales
        Cells(15, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
End If
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Untested. There is probably a better way to do this with an array but this is all I could come up with right now. Let me know:
Code:
Option Explicit
Sub MoveSalesToSheets()
Dim wbo As Workbook:    Set wbo = ActiveWorkbook
Dim wsd As Worksheet:   Set wsd = wbo.Worksheets("Data")
Dim wsphc As Worksheet: Set wsphc = wbo.Worksheets("PHC")
Dim wsapapa As Worksheet:   Set wsapapa = wbo.Worksheets("Apapa")
Dim wsvi As Worksheet:  Set wsvi = wbo.Worksheets("VI")
Dim wskano As Worksheet:    Set wskano = wbo.Worksheets("Kano")
Dim wsikeja As Worksheet:   Set wsikeja = wbo.Worksheets("Ikeja")
Dim Msg As String
Application.ScreenUpdating = False
Select Case wsphc.Cells(2, 1).Value
    Case Is = "Jan"
        x = 4
    Case Is = "Feb"
        x = 5
    Case Is = "Mar"
        x = 6
    Case Is = "Apr"
        x = 7
    Case Is = "May"
        x = 8
    Case Is = "Jun"
        x = 9
    Case Is = "Jul"
        x = 10
    Case Is = "Aug"
        x = 11
    Case Is = "Sep"
        x = 12
    Case Is = "Oct"
        x = 13
    Case Is = "Nov"
        x = 14
    Case Is = "Dec"
        x = 15
    Case Else
        Msg = MsgBox("An incorrect month is enterend in cell A2", vbOKOnly, "Error")
        Exit Sub
End Select
        wsphc.Select
        Cells(x, 2).FormulaR1C1 = "=SUMIF(Data!C,PHC!R2C2,Data!C[1])"
        Cells(x, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],PHC!R2C5,Data!C[-2])"
        Cells(x, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],PHC!R2C8,Data!C[-5])"
        Cells(x, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],PHC!R2C11,Data!C[-8])"
        Cells(x, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],PHC!R2C14,Data!C[-11])"
        Cells(x, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],PHC!R2C17,Data!C[-14])"
        wsapapa.Select
        Cells(x, 2).FormulaR1C1 = "=SUMIF(Data!C,Apapa!R2C2,Data!C[1])"
        Cells(x, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Apapa!R2C5,Data!C[-2])"
        Cells(x, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Apapa!R2C8,Data!C[-5])"
        Cells(x, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Apapa!R2C11,Data!C[-8])"
        Cells(x, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Apapa!R2C14,Data!C[-11])"
        Cells(x, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Apapa!R2C17,Data!C[-14])"
        wsvi.Select
        Cells(x, 2).FormulaR1C1 = "=SUMIF(Data!C,VI!R2C2,Data!C[1])"
        Cells(x, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],VI!R2C5,Data!C[-2])"
        Cells(x, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],VI!R2C8,Data!C[-5])"
        Cells(x, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],VI!R2C11,Data!C[-8])"
        Cells(x, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],VI!R2C14,Data!C[-11])"
        wskano.Select
        Cells(x, 2).FormulaR1C1 = "=SUMIF(Data!C,Kano!R2C2,Data!C[1])"
        Cells(x, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Kano!R2C5,Data!C[-2])"
        Cells(x, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Kano!R2C8,Data!C[-5])"
        Cells(x, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Kano!R2C11,Data!C[-8])"
        wsikeja.Select
        Cells(x, 2).FormulaR1C1 = "=SUMIF(Data!C,Ikeja!R2C2,Data!C[1])"
        Cells(x, 5).FormulaR1C1 = "=SUMIF(Data!C[-3],Ikeja!R2C5,Data!C[-2])"
        Cells(x, 8).FormulaR1C1 = "=SUMIF(Data!C[-6],Ikeja!R2C8,Data!C[-5])"
        Cells(x, 11).FormulaR1C1 = "=SUMIF(Data!C[-9],Ikeja!R2C11,Data!C[-8])"
        Cells(x, 14).FormulaR1C1 = "=SUMIF(Data!C[-12],Ikeja!R2C14,Data!C[-11])"
        Cells(x, 17).FormulaR1C1 = "=SUMIF(Data!C[-15],Ikeja!R2C17,Data!C[-14])"
        Cells(x, 20).FormulaR1C1 = "=SUMIF(Data!C[-18],Ikeja!R2C20,Data!C[-17])"
 
Application.ScreenUpdating = True
End Sub

Note: I went off the quick look that the only thing changing was the Row reference. If this is incorrect then disregard this.
 
Upvote 0
dear stnkynts,

thanks for your effort, this works perfectly, what a good logic.

appreciate if you can do it with array on your free time, this will assist me in improving my skills with array.

thanks again
 
Upvote 0
dear all
appreciate if you can assist me doing the below code with Array

thanks for stnkynts for assisting in reducing the code.
 
Upvote 0
I'm not sure what you mean by doing it with an array (there is one) but try this on a workbook you're happy to delete:
Code:
Sub blah()
Dim MonthOffset, sht, lastCol, colNo
On Error Resume Next
MonthOffset = Month(DateValue(Sheets("PHC").Range("A2").Value & ", 2000")) + 3
On Error GoTo 0
If IsEmpty(MonthOffset) Then
  MsgBox "An incorrect month is enterend in cell A2", vbOKOnly, "Error"
  Exit Sub
Else
  For Each sht In Sheets(Array("PHC", "Apapa", "VI", "Kano", "Ikeja"))
    Select Case sht.Name
      Case "Apapa", "PHC": lastCol = 17
      Case "VI": lastCol = 14
      Case "Kano": lastCol = 11
      Case "Ikeja": lastCol = 20
    End Select
    For colNo = 2 To lastCol Step 3
      sht.Cells(MonthOffset, colNo).FormulaR1C1 = "=SUMIF(Data!C2,R2C,Data!C3)"
    Next colNo
  Next sht
End If
End Sub
I've removed the references to the sheet the formulae are on they're not needed), changed the absolute/relative addresses, but I'm fairly sure they remain correct. Up to you to check.
 
Upvote 0
dear p45cal

don't know what to say :), this worked perfeclty. i tried it for all month and it worked for all sheets.

i am really grateful. this is what i needed, well we keep learning every day , imagine i wrote the code and i was about 900 rows and now it is about 20 rows.:laugh:

please if you can just explain it for me on your free time.

thanks again.
 
Upvote 0
dear p45cal

after one hour :) of debugging your code , i succeded to understand it.

the only point that is confusing me is the 2000
in vba if i replace the 2000 with any number even zero the code will work ? so what is the purpose of it

if i try in excel, it will work with any number above 2000 but will not work if the number is less than 2000.
i didn't get it
i need to know the concept of concatenating the 2000 with the formula

please advise
Excel Workbook
D
374
PHC
Excel 2010
Cell Formulas
RangeFormula
D37=MONTH(DATEVALUE(A2&2000))+3
Excel Workbook
NameRefers To
Month=PHC!$A$20:$A$31
Workbook Defined Names


thanks in advance.
 
Upvote 0
dear

sorry to disturb you again , now and after 3 hours :) i figure it out.

i understood the code complety.

thanks you really assisted in improving my skills .
 
Upvote 0
It was sleep time here in the UK when you posted the above, so I wasn't ready to do anything until this morning, however, you seem to have taught yourself, which I'm sure will mean you've learnt more than being told by me!
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

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