Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88868

Macro to copy data from one sheet to a TEMPLATE based on condition [closed]

$
0
0

I have a Macro to copy data from one excel sheet to another (TEMPLATE).

Step 1: Filter for Column L on PENDING

Step 2 : Filter for Column K for the sourcing country and Column C for destination country.

If Column K = Column C

Then go to Step 3

Step 3 : Go through Column J and Column C

If either of the values in the columns is not equal to A 1 , A 2 , A 3 , A 4 , A 5 Then Go to Step 4 If either of the values in the columns is equal to A 1 , A 2 , A 3 , A 4 , A 5 then ignore that because we don't want that to be copied

Step 4: Copy (only values in the columns which is not equal to A 1 , A 2 , A 3 , A 4 , A 5 ) the data from the current sheet and create a new file based on a TEMPLATE(start to copy data from 2nd line) Data to be copied from 2nd line new template in the following manner:

Copy Paste in the TEMPLATE Column J TO Column G
Column I TO Column F Column C TO Column A Column D TO Column B Column H TO Column C

Also the Column D should be filled in as Request all the time.

enter image description here

Step 5: After all of the above is done the TEMPLATE with the copied data should pop up so that I can verify and save it wherever I want to.

Step 6: Copy the data in the following manner and PASTE INTO ANOTHER TEMPLATE

Column J TO Column A
Column C TO Column B Column D TO Column E Column H TO Column F

The TEMPLATE should pop up so that I can verify and save it wherever I want.

I have some of the code written (NOT FOR STEP 6), but just wanted to make sure it is perfectly correct. I am not able to post the code, its giving me formatting errors.

Sub SS()

    ' SS Macro
    ''
    ActiveSheet.Range("$A$1:$O$757").AutoFilter Field:=12, Criteria1:="PENDING"
    ActiveWindow.SmallScroll Down:=-15
    ActiveSheet.Range("$A$1:$O$757").AutoFilter Field:=11, Criteria1:="USA"
    ActiveWindow.SmallScroll Down:=-18
    ActiveSheet.Range("$A$1:$O$757").AutoFilter Field:=10
    ActiveWindow.SmallScroll Down:=-42
    Windows("TEMPLATE.xlsx").Activate
    ActiveWindow.SmallScroll Down:=-18
    Windows("Transfers 2020 - Roy.xlsx").Activate
    ActiveWindow.SmallScroll Down:=-12
    Range("I407").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range("I407:J407").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Windows("TEMPLATE.xlsx").Activate
    Range("F2").Select
    ActiveSheet.Paste
    Windows("Transfers 2020 - Roy.xlsx").Activate
    ActiveWindow.SmallScroll Down:=-81
    Range("C407:D407").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("TEMPLATE.xlsx").Activate
    Range("A2").Select
    ActiveSheet.Paste
    ActiveWindow.SmallScroll Down:=-39
    Windows("Transfers 2020 - Roy.xlsx").Activate
    Range("H420").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("TEMPLATE.xlsx").Activate
    Range("C2").Select
    ActiveSheet.Paste
    Range("D2:E2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("D3:E3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("D3:E1048569").Select
    Selection.End(xlUp).Select
    Range("D2:E53").Select
    ActiveSheet.Paste
    ActiveWindow.SmallScroll Down:=-6
    Windows("Transfers 2020 - Roy.xlsx").Activate
    ActiveWindow.SmallScroll Down:=-78
    Range("H407:H408").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("TEMPLATE.xlsx").Activate
    Range("C2").Select
    ActiveSheet.Paste
    ActiveWindow.SmallScroll Down:=-63
    Windows("Transfers 2020 - Roy.xlsx").Activate
    End Sub 

PLEASE HELP! THANK YOU IN ADVANCE.


Viewing all articles
Browse latest Browse all 88868

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>