Two different sheet data to be pasted on one another sheet

vishu123

New Member
Joined
Jul 26, 2019
Messages
6
I have a excel sheet where Sheet 2 named as 'master sheet' and sheet 3 named as 'revenue data'. I want to enter the company name in cell G2 in sheet 1 which will search the same name in column F of 'Master Sheet' and paste it in sheet 1 below master header. Similary the value of G2 needs to be searched in column B of 'Revenue Sheet' and then paste it in the sheet 1 below Revenue header.


Fro example: if I write 'Moto' in cell G2 and on clicking on Submit button then Moto name should be searched in both the Master & Revenue sheet and output should be pasted in the sheet 1 below each headers.


I don't have any knowledge of macro. Can you please help me in creating macro for the same
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Master Tab has below data:

NameGroupTypeYearDesignationCompanyLink
AnuragabcEmployeeCurrentAssociateNokiasjdchbdjh
AmitdefCustomerPreviousNone1 Storeascvsdjcv
AnilabcCustomerCurrentNone2 Storeasdcbhsd
AdityajklCustomerPreviousAssociateSamsungasdcbhjdc
KautidefEmployeePreviousAssociateSamsungsdccd
AbhixyzInvestorCurrentAssociateDellasdjhcb
KunwerInvestorCurrentAssociateMototyhyh
ArtdrfCustomerCurrentNoneLYFcvbn
MaixyzInvestorCurrentAssociateMotoert

<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" span="16" style="width:48pt"></colgroup><tbody>
</tbody>
Revenue has below data:

IdSupplier NameYear 1Year 2Year 3Year 4Year 5Web Link
11apple6587946754sdcsd
22Dell7296555572zxc
33LG8153598878ghnhn
44Samsung Pvt6988747586cgfh
55Dell5581728461hjm
66Moto Inc8673796176dryty
77Moto5458886393bfbgb
88LYF7269755483wrtt
99Dell Ltd5497589562wer
12LYF Mobile5086537950dfbgb
13apple8269897364tyh
14Samsung8994807250gfhnh
15LG7490559599sdtr

<colgroup><col width="64" span="8" style="width:48pt"> </colgroup><tbody>
</tbody>


I want in sheet 1 if I enter Moto in G2 then it should show me data in sheet 1 like:



Under Master Tab it must show:

NameGroupTypeYearDesignationCompanyLink
KunwerInvestorCurrentAssociateMototyhyh
MaixyzInvestorCurrentAssociateMotoert

<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>
</tbody>


Under Revenue header it must show

IdSupplier NameYear 1Year 2Year 3Year 4Year 5Web Link
66Moto Inc8673796176dryty
77Moto5458886393bfbgb

<colgroup><col width="64" span="8" style="width: 48pt;"></colgroup><tbody>
</tbody>
 
Upvote 0
Output would look like this:

Moto
clip_image002.png

<tbody>
</tbody>
Master SheetRevenue
NameGroupTypeYearDesignationCompanyLinkIdSupplier NameYear 1Year 2Year 3Year 4Year 5Web Link
KunwerInvestorCurrentAssociateMototyhyh66Moto Inc8673796176dryty
MaixyzInvestorCurrentAssociateMotoert77Moto5458886393bfbgb

<colgroup><col span="18"></colgroup><tbody>
</tbody>
 
Upvote 0
Try this

Change data in red by your information.
Code:
Sub [B][COLOR=#0000ff]Copy_Data[/COLOR][/B]()
  Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  Set sh1 = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
  Set sh2 = Sheets("[COLOR=#ff0000]Master[/COLOR]")
  Set sh3 = Sheets("[COLOR=#ff0000]Revenue[/COLOR]")
  
  sh1.Rows("3:" & Rows.Count).Clear
  sh2.Range("A1").AutoFilter Field:=6, Criteria1:="=*" & sh1.Range("G2") & "*"
  sh3.Range("A1").AutoFilter Field:=2, Criteria1:="=*" & sh1.Range("G2") & "*"
  sh2.AutoFilter.Range.EntireRow.Copy sh1.Range("A4")
  sh3.AutoFilter.Range.EntireRow.Copy sh1.Range("A" & Rows.Count).End(xlUp)(3)
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Copy_Data) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Thanks a ton DanteAmor !!! This is working for me.

Only one change I want in this - after searching the records, it should paste side- by- side data for Master and revenue sheet with one blank column as separator.
 
Upvote 0
Master sheet have 7 columns so it should be pasted from cell A to cell G

Revenue sheet have 17 columns , so it should be pasted from cell I to cell W.

Also I want above Master's pasted Data, 7 cells merged and should be named as Master with Light Green Background. Similarly, above Revenue pasted data, 15 cells merged and should be named as Revenue with light blue background.

This will be really helpful if you can share codes on the basis of this requirement.

Thanks in Advance !!!
 
Upvote 0
Master sheet have 7 columns so it should be pasted from cell A to cell G

Revenue sheet have 17 columns , so it should be pasted from cell I to cell W.

Also I want above Master's pasted Data, 7 cells merged and should be named as Master with Light Green Background. Similarly, above Revenue pasted data, 15 cells merged and should be named as Revenue with light blue background.

This was not in the original requirement, it is better if you create a new thread.

This will be really helpful if you can share codes on the basis of this requirement.

Thanks in Advance !!!


Try this

To leave a separation column.

Sub Copy_Data()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Master")
Set sh3 = Sheets("Revenue")

sh1.Rows("3:" & Rows.Count).Clear
sh2.Range("A1").AutoFilter Field:=6, Criteria1:="=*" & sh1.Range("G2") & "*"
sh3.Range("A1").AutoFilter Field:=2, Criteria1:="=*" & sh1.Range("G2") & "*"
sh2.AutoFilter.Range.EntireRow.Copy sh1.Range("A4")
sh3.AutoFilter.Range.CurrentRegion.Copy sh1.Range("I4")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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