Copy in a tab from another workbook

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
This is and is not a continuation of another question. I was told that what I asked in the previous post was not possible so I am trying another (much different) approach.

Please excuse me if I am not posting this correctly.

I have code that opens another workbook and pastes in the other workbooks File name and address. Is there a way to add to this code so that it copies in the tab names "Pricing Matrix" from the other workbook.

Overall, I am trying to get data into one workbook from another so that I can do a comparison. At first I though I could compart data from two separate workbooks using an indirect formula (Which I now understand is not possible). So now I am hoping I can copy the table in from another workbook so I can do the comparison. Please note that I am not only comparing the values but also I want to check the data (example I want to make sure the value is a number or a date.... that is why I need to copy in the table or copy over the entire tab.

Hope this makes sense and my apologies for multiple posts.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Figured it out.

Code:
Sub Get_Data_1()

    ' Retrieve Current Workbook Name
    Dim SentRFQTemplate As Workbook, FileName
    Dim sourceSheet2 As Worksheet
    
    ' Open Dialog Box to Select File to Copy From & Save it's Name in a Variable
    MsgBox "Select the firs workbook to compare - Sent RFQ Tool."
    
    FileName = Application.GetOpenFilename _
    (filefilter:="Excel files (*.xl*),*.xl*", MultiSelect:=False)
    If FileName = False Then Exit Sub
    Set SentRFQTemplate = Workbooks.Open(FileName, ReadOnly:=True)
    
    ' *** This will put the address of the opened file in Tracker sheet cell C4 ***
    ThisWorkbook.Sheets("Main").Range("B10") = Application.ActiveWorkbook.FullName
    
    
    ' Copy in Pricing Matrix tab
    Set sourceSheet2 = SentRFQTemplate.Sheets("Pricing Matrix")
    sourceSheet2.Copy After:=ThisWorkbook.Sheets("Main")
    
    
    ' Close Extra Workbook
    SentRFQTemplate.Close 0
    
    ' Rename the imported tab
    Sheets("Pricing Matrix").Select
    Sheets("Pricing Matrix").Name = "Pricing_Matrix_1"
    Sheets("Pricing_Matrix_1").Range("A2").Value = Sheets("Main").Range("B10")

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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