I am trying to insert the correct country map JPG in the correct country XLSX. By "correct" I mean there is one map for each XLSX - Albania.jpg into Albania.xlxs, Andorra.jpg into Andorra.xlxs, etc.
My macro is to do the following:
Enter country name and year in User Form worksheet cells B2 and B3 (works fine!).
Enter country population and income level in Countries worksheet cells B1 and E1 (works fine!).
Insert country map JPG in User Form worksheet at cell A18 (cannot get this to loop!).
Save the workbook as CountryName.xlxs (works fine!).
I have tried using Filename = Dir(Path & "*.jpg") and ActiveSheet.Pictures.Insert without success. I think I need to use ActiveSheet.Pictures.Insert because the cells above the map's position (cell A18) will expand and the map needs to move down.
Sub SaveCountryYear_XLSX_English_map()
Dim lRow, x As Integer
Dim wbName As String
Dim MapPath As String 'Not used in example below
Dim MapName As String 'Not used in example below
Dim index As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
lRow = Range("A" & Rows.Count).End(xlUp).Row
x = 1
Do
x = x + 1
Worksheets("Countries").Activate
'1. Enter country name and year in User Form worksheet cells B2 and B3.
Range("A" & x).Select
Selection.Copy
Sheets("User Form").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Countries").Select
Range("B" & x).Select
Selection.Copy
Sheets("User Form").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'2. Enter country population and income level in Countries worksheet cells B1 and E1.
Sheets("Countries").Select
Range("C" & x).Select
Selection.Copy
Sheets("Table").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Countries").Select
Range("D" & x).Select
Selection.Copy
Sheets("Table").Select
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'3. Insert country map JPG in User Form worksheet at cell A18
'(cannot get this to loop!).
'The following is just an example - it works,
'but without loop of course (inserts the named file correctly).
Sheets("User Form").Select
Range("A18").Select
ActiveSheet.Pictures.Insert( _
"C:\temp\profiles\2017\Maps\EN JPGs\Albania_EN.jpg").Select
Sheets("Countries").Select
'4. Save the workbook as CountryName.xlxs.
wbName = Range("A" & x).Value & "_" & Range("B" & x).Value & "_EN"
ActiveWorkbook.SaveAs Filename:="C:\temp\profiles\2017\Production\Batch_EN_1\" _
& wbName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Loop Until x = lRow
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
edited after OP's clarifications
you may want to try this refactored code:
Option Explicit
Sub SaveCountryYear_XLSX_English_map()
Dim wbName As String
Dim MapPath As String 'Not used in example below
Dim MapName As String 'Not used in example below
Dim index As Integer 'Not used in example below
Dim cell As Range
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With Worksheets("Countries") '<--| reference "Countries" worksheet of your currently active workbook
For Each cell In .Range("A2", .Cells(.Rows.Count, 1).End(xlUp)).SpecialCells(XlCellType.xlCellTypeConstants, xlTextValues) '<--| loop through referenced worksheet column A cells filled with some text from A2 down to last not empty one
'1. Enter country name and year in User Form worksheet cells B2 and B3.
Worksheets("User Form").Range("B2").value = cell.value '<--| name is in current cell
Worksheets("User Form").Range("B3").value = cell.Offset(, 1).value '<--| date is in adjacent cell
'2. Enter country population and income level in Countries worksheet cells B1 and E1.
Worksheets("Table").Range("B1").value = cell.Offset(, 2).value '<--| population is in cell two columns right of current one
Worksheets("Table").Range("E1").value = cell.Offset(, 3).value '<--| income level is in cell three columns right of current one
'3. Insert country map JPG in User Form worksheet at cell A18
'(cannot get this to loop!).
'The following is just an example - it works,
'but without loop of course (inserts the named file correctly).
Worksheets("User Form").Activate
Range("A18").Select
ActiveSheet.Pictures.Insert _
"C:\temp\profiles\2017\Maps\EN JPGs\" _
& cell.value & "_EN.jpg"
'4. Save the workbook as CountryName.xlxs.
Worksheets.Copy '<--| copy current workbook worksheets to a new workbook
ActiveWorkbook.SaveAs Filename:="C:\temp\profiles\2017\Production\Batch_EN_1\" _
& wbName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
Next cell
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
where:
you have to adapt:
ActiveSheet.Pictures.Insert _
"C:\temp\profiles\2017\Maps\EN JPGs\" _
& cell.value & "_EN.jpg"
to your actual filenames and source path conventions
I changed section 4 (Save the workbook as CountryName.xlxs)
Related
I have a Master Sheet called ContactsforEmails from this workbook, I am copying the header into every new workbook.
Then, I am copying and pasting every 40 rows starting at A2 until I column. The new workbook is saved and closed. Then I want to loop back create another new Workbook name it "EmailList(next number)" and so copy the next 40. Then run till the next cell in the A column is blank.
I have managed to copy the header,save as a new document,and copy the first 40.
I haven't figured out how to make it loop correctly, I suspect it is with DoUntil loop and Offset. But I am hoping someone more advanced in this can advise.
The error I run into is "Run-time error 9: Subscript out of range."
Here is my attempt:
'Copy Header
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Rows("1:1").EntireRow.AutoFit
'Save File As New Name
Dim fpath As String
Dim fcount As Integer
Dim fname As String
Do While Len(Dir(fpath & fname)) <> 0
fpath = "C:\Users\Path\"
fcount = fcount + 1
fname = "EmailList" & fcount & ".xlsx"
Loop
ActiveWorkbook.SaveAs Filename:=fpath & fname
'Copy and Paste 40
Windows("ContactsForEmails.xlsx").Activate
Dim fcopy As Range
Set fcopy = Range("A2:H41")
fcopy.Select
Selection.Copy
Windows(fname).Activate
Range("A2").Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Do Until IsEmpty(fcopy)
fcopy.Offset(40, 0).Select
Selection.Copy
Windows(fname).Activate
Range("A2").Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Loop
End Sub
I created MACRO in my order calculation template to deleted some unnecessary rows and save a sheet as workbook with "name". MACRO works great, but where is one annoying problem, I every time have change it this workbook name according to order number. So, I want to create/improve my MACRO to save sheet as workbook with cell name (this cell range "G1").
Could someone have ideas how to do this?
Sub Pirmoji()
'
' Pirmoji Macro
Sheets("Svorio Patvirtinimo dok").Select
ActiveSheet.Shapes.Range(Array("Column1")).Select
Sheets("Svorio Patvirtinimo dok").Copy
Rows("1:6").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=66
Dim LastRow As Long, myCell As Range, myRange As Range
Dim myCell1 As Range
LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
Set myCell1 = Range("A" & LastRow)
Cells.Find(What:="• Praau atkreipti d?mes?:", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Set myCell = ActiveCell
Set myRange = Range(myCell, myCell1)
myRange.EntireRow.Delete
ActiveWindow.SmallScroll Down:=-78
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Copy
MsgBox "This new workbook will be saved as MyWb.xls(x)"
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\MyWb", xlWorkbookNormal
MsgBox "It is saved as " & ActiveWorkbook.FullName & vbLf & "Press OK to close it"
ActiveWorkbook.Close False
End Sub
The code below will fix only the relevant part of your post, how to save "Svorio Patvirtinimo dok" sheet as a new workbook, and file name according to the value in "G1".
You can do a lot of improvements also in the upper section of your code, there are a lot of unnecessary Select, Selection and ActiveCell.
Read HERE why you should avoid using Select, Activate and other similar types.
Modified Code (relevant section only):
Dim Sht As Worksheet
Dim NewWBName As String
' set the worksheet object
Set Sht = ThisWorkbook.Sheets("Svorio Patvirtinimo dok")
MsgBox "This new workbook will be saved as MyWb.xls(x)"
' set the bnew name in same path and file name according to the value in "G1"
NewWBName = ThisWorkbook.Path & "\" & Sht.Range("G1").Value2 & ".xlsx"
'save sheet as workbook with the name in cell "G1"
Sht.SaveAs NewWBName, 51 ' save format 51 - .xlsx
MsgBox "It is saved as " & NewWBName & vbLf & "Press OK to close it"
ActiveWorkbook.Close False
I am looking for advice on how to write a macro that does the below. I imagine its easy to do, but I can't figure it out. Thanks in advance!
START
In the active sheet (in the workbook I am running this macro in [Title changes but same formatting each time]), copy cell B9. Paste in column A on the next blank row of the other workbook I am using [Can have the same title every time I run this process, or just be the only other workbook open]
In the active sheet (in the workbook I am running this macro in), copy cell B8. Paste in column B of the row identified above.
In the active sheet (in the workbook I am running this macro in), copy cell B12. Paste in column C of the row identified above.
In the active sheet (in the workbook I am running this macro in), copy cells A17:E17. Paste in D:H of the row identified above.
In the active sheet (in the workbook I am running this macro in), copy cells A17:E17. Paste in D:H of the row identified above.
In the active sheet (in the workbook I am running this macro in), copy cells G17:N17. Paste in I:P of the row identified above.
END
Given my lack of vba coding ability I'm trying to record a macro and then adjust. I've tried as many options as I can find on google. The below seems to be the best, but doesn't work. (NB: I start with B9 from point 1 above selected).
Sub Copy_Timesheet()
'
' Copy_Timesheet Macro
'
'
Selection.Copy
Windows("WorkbookB").Activate
Find_Blank_Row()
Dim BlankRow As Long
BlankRow = Range("A65536").End(xlUp).Row + 1
Cells(BlankRow, 1).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Activate
ActiveCell.Offset(3, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WorkbookB").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Activate
ActiveCell.Offset(-4, 0).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WorkbookB").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Activate
ActiveCell.Offset(9, -1).Range("A1:E1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WorkbookB").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ThisWorkbook.Activate
ActiveCell.Offset(0, 6).Range("A1:H1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("WorkbookB").Activate
ActiveCell.Offset(0, 5).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Now that you have shown some effort in generating the code, here is a refactored version of what you said you were after. (I didn't check to see whether that matched what you actually recorded, but the fact that you went to the trouble of recording something indicated that you weren't just too lazy to do this yourself.)
Sub Copy_Timesheet()
'Set up some objects to make life easier in the rest of the code
' "the active sheet (in the workbook I am running this macro in)"
Dim wsSrc As Worksheet
Set wsSrc = ThisWorkbook.ActiveSheet
'the sheet in the other workbook
Dim wsDst As Worksheet
Set wsDst = Workbooks("WorkbookB").Worksheets("destination_sheet_name") 'change sheet name to whatever you need
Dim BlankRow As Long
'Fully qualify ranges so that we ensure we are working with the sheet we expect to be
'Use Rows.Count rather than 65536 just in case we are working in a recent workbook that allows 1048576 rows
BlankRow = wsDst.Range("A" & wsDst.Rows.Count).End(xlUp).Row + 1
'In the active sheet (in the workbook I am running this macro in [Title changes but same formatting each time]), copy cell B9. Paste in column A on the next blank row of the other workbook I am using [Can have the same title every time I run this process, or just be the only other workbook open]
wsDst.Range("A" & BlankRow).Value = wsSrc.Range("B9").Value
'In the active sheet (in the workbook I am running this macro in), copy cell B8. Paste in column B of the row identified above.
wsDst.Range("B" & BlankRow).Value = wsSrc.Range("B8").Value
'In the active sheet (in the workbook I am running this macro in), copy cell B12. Paste in column C of the row identified above.
wsDst.Range("C" & BlankRow).Value = wsSrc.Range("B12").Value
'In the active sheet (in the workbook I am running this macro in), copy cells A17:E17. Paste in D:H of the row identified above.
wsDst.Range("D" & BlankRow & ":H" & BlankRow).Value = wsSrc.Range("A17:E17").Value
'In the active sheet (in the workbook I am running this macro in), copy cells A17:E17. Paste in D:H of the row identified above.
'No need to do this - we just did it
'In the active sheet (in the workbook I am running this macro in), copy cells G17:N17. Paste in I:P of the row identified above.
wsDst.Range("I" & BlankRow & ":P" & BlankRow).Value = wsSrc.Range("G17:N17").Value
End Sub
Sub copysheet()
Dim wb As Workbook
Dim wb1 As Workbook
application.screenupdating=False
application.DisplayAlerts=False
On error goto resetsettings
MyPath = "C:\Users\foo\" 'The folder containing the files you want to use
MyExtension = "*.xlsx" 'The extension of the file you want to use
Myfile = Dir(MyPath & MyExtension)
Set wb = ThisWorkbook
While Myfile <> ""
Set wb1 = Workbooks.Open(MyPath & Myfile)
lr = wb1.Sheets(1).Range("A1:A" & Rows.Count).End(xlUp).Row + 1
wb.Sheets(1).Range("B9").Copy Destination:=wb1.Sheets(1).Range("A" & lr)
wb.Sheets(1).Range("B8").Copy Destination:=wb1.Sheets(1).Range("B" & lr)
wb.Sheets(1).Range("B12").Copy Destination:=wb1.Sheets(1).Range("C" & lr)
wb.Sheets(1).Range("A17:E17").Copy Destination:=wb1.Sheets(1).Range("D" & lr & ":H" & lr)
wb.Sheets(1).Range("G17:N17").Copy Destination:=wb1.Sheets(1).Range("I" & lr & ":P" & lr)
wb1.close Savechanges:=True
Myfile = Dir
Wend
ResetSettings:
application.screenupdating=True
application.DisplayAlerts=True
End Sub
This Macro will loop through all Xlsx Files in a folder and make the above changes in the files and closes them.
I have 26 worksheets every week that contain a "Station #", "Latitude#", and a "Longitude#".
I want to create a Macro that grabs these 3 cells, copies them and places them into 3 columns named "Station #", "Lat", and "Long.
I'm not very good at this so i need some help.
This is what i got so far:
Sub Macro1()
FolderName = "C:\Users\Captain Wypij\Desktop\Traffic\test"
If Right(FolderName, 1) <> Application.PathSeparator Then FolderName = FolderName & Application.PathSeparator
Fname = Dir(FolderName & "*.xls")
'loop through the files
Do While Len(Fname)
With Workbooks.Open(FolderName & Fname)
Range("C8:D8").Select
Selection.Copy
ChDir "C:\Users\Captain Wypij\Desktop\Traffic"
Workbooks.Open Filename:= _
"C:\Users\Captain Wypij\Desktop\Traffic\Test.xls.xlsx"
Range("A2").Select
If ("A2") = "*" Then Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks.Open (FolderName & Fname)
ActiveWindow.SmallScroll Down:=12
Range("C34:D34").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Test.xls.xlsx").Activate
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks.Open (FolderName & Fname)
Range("G34:H34").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Test.xls.xlsx").Activate
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks.Open (FolderName & Fname)
ActiveWindow.Close
Windows("Test.xls.xlsx").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End With
' go to the next file in the folder
Fname = Dir
Loop
End Sub
I cant seem to figure out how to paste the next worksheet i open in the next fields ( such as A3, B3, C3 and so forth.
Please help me!
Try this:
Dim FolderName As String, Fname As Variant
FolderName = "C:\Location\Folder\"
Fname = Dir(FolderName & "*.xlsx")
Dim wb As Workbook, ws As Worksheet, lr as long
Do While Fname <> ""
Set wb = Workbooks.Open(FolderName & Fname)
Set ws = wb.Sheets("SheetName") '~~> Change to suit
With Thisworkbook.Sheets("Sheet1") '~~> Change to suit
lr = .Range("A" & .Rows.Count).End(xlUp).Row + 1
ws.Range("C8:D8").Copy: .Range("A" & lr).PasteSpecial xlPasteValues
ws.Range("C34:D34").Copy: .Range("B" & lr).PasteSpecial xlPasteValues
ws.Range("G34:H34").Copy: .Range("C" & lr).PasteSpecial xlPasteValues
End With
wb.Close False
Set wb = Nothing: Set ws = Nothing
Fname = Dir
Loop
Above code basically opens all .xlsx file in the specified folder and then copies static ranges. This static ranges are the ones you specified in your question (e.g. Range("C8:D8")). So it copies it and paste it as values on the sheet you will specify. It finds the last row on the destination sheet which will put the copied values below it.
Is this what you're trying? HTH.
Here is my challenge. I try to copy and paste data based on Currency and Dates to a newly created Worksheets in the same Workbook. Each newly created Worksheet should be named by Currency and Date from the main source. I am stuck with dates and I am not sure how to add other currencies. Please advise. Thank you very much.
Option Explicit
Sub Create_Copy_of_JE_DATA_Split_By_Currency_AND_By_Date()
Dim draft As Worksheet
Dim curr_date As Worksheet
Dim LastRow
Dim LastColumn As Integer
Dim i
Dim drafttable As Object
Dim Curr As String
Dim transdate As Date
'Clean up previous data before start the macro
Application.DisplayAlerts = False
For Each i In ActiveWorkbook.Worksheets
If i.name = "Draft_Data" Then i.Delete
Next i
For Each i In ActiveWorkbook.Worksheets
If i.name = "Currency_Date" Then i.Delete
Next i
Application.DisplayAlerts = True
'Create a draft sheet to work with data
Sheets("JE_data").Select
Sheets("JE_data").Copy After:=Sheets(Sheets.count)
ActiveSheet.name = "Draft_Data"
Set draft = Sheets("Draft_Data")
LastRow = draft.Range("A1").End(xlDown).End(xlDown).End(xlUp).Row
LastColumn = draft.Range("A1").End(xlToRight).Column
'Copy Currency and Date data to find unique data
'It depends on your data structure, the original assumption was that column C is currency and column D is transaction Date
'The actual data structure is different - Currency is Column "P" and Date is Column "W",
'so I would have to delete Columns between them
Range("P2:W" & LastRow).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.count)
ActiveSheet.name = "Currency_Date"
Set curr_date = Sheets("Currency_Date")
ActiveSheet.Paste
Application.CutCopyMode = False
With Sheets("Currency_Date")
.Columns("B:G").EntireColumn.Delete
.Range("$A$1:$B$" & LastRow).RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo
End With
'ActiveSheet.Range("$A$1:$B$" & LastRow).RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo
'Select Draft sheet and start filtering
draft.Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$W$" & LastRow), , xlYes).name = "Draft_table"
'so when I filter it, it will have the same format.
'it's upto you to choose the date format, :) I'm in Australia so I choose d/mm/yyyy
Columns("W:W").Select
Selection.NumberFormat = "d/mm/yyyy;#"
Set drafttable = draft.ListObjects("Draft_table")
'The idea is for each unique value of currency and date pair, we will filter this Draft 'table
'and copy the result to a new sheet then rename this sheet.
For i = 1 To Sheets("Currency_Date").Range("A1").End(xlDown).End(xlDown).End(xlUp).Row
Curr = curr_date.Range("A" & i).Value
transdate = curr_date.Range("B" & i).Value
draft.Select
drafttable.Range.AutoFilter Field:=16, Criteria1:=Curr
drafttable.Range.AutoFilter Field:=23, Criteria1:=transdate
drafttable.Range.AutoFilter Field:=23, Criteria1:="=" & transdate, Operator:=xlAnd
Range("Draft_table").SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.count)
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.name = Format(transdate, "MMM DD YYYY") & " " & Curr
Sheets("JE_Data").Select
Rows("1:1").Select
Selection.Copy
Sheets(Format(transdate, "MMM DD YYYY") & " " & Curr).Select
Rows("1:1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.EntireColumn.AutoFit
'Prepare for next filter.
draft.ShowAllData
Next i
'draft.Delete
'curr_date.Delete
End Sub
I don't know how your data look like, so I use a simple data like below:
ID Name Currency Transaction_Date
1 A AUD 1/08/2014
2 B USD 2/08/2014
3 C GBP 4/08/2014
4 D JPY 10/09/2014
5 E AUD 4/08/2014
6 F USD 10/09/2014
7 A GBP 1/08/2014
8 B JPY 2/08/2014
9 C AUD 4/08/2014
10 D USD 10/09/2014
My idea is create a list of unique value (Currency,Transaction date), then using filter to get data with 2 criterial: Currency and Data. Doesn't matter how many rows you have, it should work the same.
Copy the filtered data to new sheet and rename this sheet to DATE & Currency as required.
When I test, this works perfectly
(I have not clean my code yet, so please modify it as you need)
Sub Create_Copy_of_JEDATA()
Dim draft, curr_date As Worksheet
Dim LastRow, LastColumn As Integer
'Clean up previous data before start the macro
Application.DisplayAlerts = False
For Each i In ActiveWorkbook.Worksheets
If i.Name = "Draft_Data" Then i.Delete
Next i
For Each i In ActiveWorkbook.Worksheets
If i.Name = "Currency_Date" Then i.Delete
Next i
Application.DisplayAlerts = True
'Create a draft sheet to work with data
Sheets("JE_data").Select
Sheets("JE_data").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Draft_Data"
Set draft = Sheets("Draft_Data")
LastRow = draft.Range("A1").End(xlDown).End(xlDown).End(xlUp).Row
LastColumn = draft.Range("A1").End(xlToRight).Column
'Copy Currency and Date data to find unique data
'Depend on your data structure, I assume that column C is currency and column D is transaction Date
Range("C2:D" & LastRow).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Currency_Date"
Set curr_date = Sheets("Currency_Date")
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$B$" & LastRow).RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo
'Select Draft sheet and start filtering
draft.Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$D$" & LastRow), , xlYes).Name = "Draft_table"
'so when I filter it, it will have the same format.
'it's upto you to choose the date format, :) I'm in Australia so I choose d/mm/yyyy
Columns("D:D").Select
Selection.NumberFormat = "d/mm/yyyy;#"
Set DraftTable = draft.ListObjects("Draft_table")
'The idea is for each unique value of currency and date pair, we will filter this Draft table
'and copy the result to a new sheet then rename this sheet.
For i = 1 To Sheets("Currency_Date").Range("A1").End(xlDown).End(xlDown).End(xlUp).Row
Curr = curr_date.Range("A" & i).Value
transdate = curr_date.Range("B" & i).Value
draft.Select
DraftTable.Range.AutoFilter Field:=3, Criteria1:=Curr
DraftTable.Range.AutoFilter Field:=4, Criteria1:="=" & transdate, Operator:=xlAnd
Range("Draft_table").SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Name = Format(transdate, "MMM DD YYYY") & " " & Curr
Sheets("JE_Data").Select
Rows("1:1").Select
Selection.Copy
Sheets(Format(transdate, "MMM DD YYYY") & " " & Curr).Select
Rows("1:1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.EntireColumn.AutoFit
'Prepare for next filter.
draft.ShowAllData
Next i
'draft.Delete
'curr_date.Delete
End Sub