Copying desired information from one workbook to another workbook with the same worksheet names

K0st4din

Well-known Member
Joined
Feb 8, 2012
Messages
501
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello, everyone.
Please for your help, I just do not know how to do it with a macro and right now I do it by hand.
I have two working books.
The first: is "Base"
The second - I transfer information about what I want from me (usually last month).
At the base I have worksheets with names (London, Paris, New York, China, etc.) and many more worksheets.
In the second workbook - I have the same worksheets: (London, Paris, New York, China, etc.).
In the workbook "Base" in the above mentioned worksheets I report information every month. Once I have applied it, she -> the information accumulates for each month back and the file becomes very large.
For each worksheet (London, Paris, New York, China, etc.), I filter the past month, for example 4.2018 (in the Base) and put the information in the second workbook only the selected month.
Please for your help, do it somehow with a macro.
The date is in column A2:to the end. Once I've chosen the date, I copy all the rows to the end. In each of the worksheets the rows are different.
A button that Somehow asked me: "What month do you want to copy and apply from Base in the other Workbook?"
Please, if there is any ambiguity, ask to help
 
Last edited:
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
Everything is alright now.
You are right, I really wrote only for a month without mentioning the desired year.
But, you're perfect and helped me again.
Thank you again cordially.
I think the topic is solved.
Have a nice weekend
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi My Aswer Is This,
this macro that I helped was great. And it has been serving me for quite some time.
I would like to use it in my other spreadsheet, but somehow I can't manage to make some slight changes to it.
Currently the macro works by filtering in column A the desired date and transfers all the information to the other worksheet by worksheet.
However, in the new table, the layout is not the same and I'm trying to replace that column A with column J, but I'm not getting things right.
The structure of the new table is as follows:
Column A - text
Column B - text
Column C and D - blank (another will fill in the information after everything has been moved from one workbook to another)
Column E, F, G - again text
Column H and I - empty again (another will fill in the information after everything has been moved from one workbook to another)
Column J - here are the dates
In this case I have to filter this column by the desired month and copy the columns back to A.
VBA Code:
Sub Test()
'Modified 5/9/2018 3:20 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
Dim b As Long
Dim Lastrow As Long
Dim Lastrowa As Long
'Dim s As Long
Dim ans As Long
Dim mon As Long
Dim WN As String
Dim WNN As String
Dim s As Variant
Dim x As Long
s = Array("Sofia", "Plovdiv", "Stara Zagora")
x = UBound(s)
WNN = "Base" & ".xlsm" 'This is copy from workbook
WN = "FinalResult" & ".xlsm" ' This is copy to workbook
mon = Month(InputBox("Enter Date for this Month", "Hello", Date))
    For b = 1 To x + 1
        
        Lastrow = Workbooks(WNN).Sheets(s(b - 1)).Cells(Rows.Count, "A").End(xlUp).Row ' [COLOR=rgb(226, 80, 65)]I try to change this A, with J !!!!!!!!!![/COLOR]
        Lastrowa = Workbooks(WN).Sheets(Sheets(s(b - 1)).Name).Cells(Rows.Count, "A").End(xlUp).Row + 1 ' [COLOR=rgb(226, 80, 65)]And here A with J !!!!!!!!!!![/COLOR]
            For i = 2 To Lastrow
                ans = Month(Workbooks(WNN).Sheets(s(b - 1)).Cells(i, 1).Value)
                If ans = mon Then Workbooks(WNN).Sheets(s(b - 1)).Rows(i).Copy Workbooks(WN).Sheets(s(b - 1)).Rows(Lastrowa): Lastrowa = Lastrowa + 1
            Next
    Next
Application.ScreenUpdating = True
End Sub
 

Attachments

  • 2019-12-02_083438.jpg
    2019-12-02_083438.jpg
    9.8 KB · Views: 5
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,212
Members
453,023
Latest member
alabaz

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