Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:50:08+00:00 2026-06-11T06:50:08+00:00

I have a workbook that I need to open and then copy the data

  • 0

I have a workbook that I need to open and then copy the data from the first tab, and then paste it to the original workbook in which the script was created from.

The problem I am running into is that the workbook and the first tab will be named the same thing. So if the workbook name is OpenPOs-100255-08292012.xls the tab is going to be OpenPOs-100255-08292012. Next week though the excel sheet is going to be OpenPOs-200211-12495312.xls which means the tab is going to be OpenPOs-200211-12495312.

With the code I am using right now, is there a way to make it work for this kind of situation? I thought about making it so that the "Sheet 1" becomes the tab of the day? I thought about using `wsPOR.Sheets(wsPOR) but I have a feeling that is going to be coming back as an error. Can someone help please?

Sub Update_TNOOR()
    Dim wsTNO As Worksheet
    Dim wsTND As Worksheet
    Dim wsTNA As Worksheet
    Dim wbPOR As Workbook               'New Workbook
    Dim wbOOR As Workbook               'ThisWorkbook
    Dim lastrow As Long, lastrow2 As Long, fstcell As Long
    Dim strFile As String, NewFileType As String, filename As String

    Set wsTNO = Sheets("Tel-Nexx OOR")
    Set wsTND = Sheets("Tel-Nexx Data")
    Set wsTNA = Sheets("Tel-Nexx Archive")
    Set wbOOR = ThisWorkbook

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .EnableEvents = False
    End With

    lastrow = wsTND.Range("A" & Rows.Count).End(xlUp).Row + 1
    wsTND.Range("A2:P" & lastrow).Delete

    strFile = Application.GetOpenFilename()
    NewFileType = "Excel Files 2007 (*.xls)"
    Set wbPOR = Application.Workbooks.Open(strFile)
    lastrow = wbPOR.Sheets("Sheet1").Range("A" & wbPOR.Sheets("Sheet1").Rows.Count).End(xlUp).Row
    wbPOR.Sheets("Sheet1").Range("A4:N" & lastrow).Copy wbOOR.Sheets("Tel-Nexx Data").Range("A2")
    wbPOR.Save
    wbPOR.Close


End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:50:10+00:00Added an answer on June 11, 2026 at 6:50 am

    Based on my comment above, your code, from strFile = Application.GetOpenFilename() to wbPOR.Close becomes:

    strFile = Application.GetOpenFilename()
    NewFileType = "Excel Files 2007 (*.xls)"
    
    Set wbPOR = Application.Workbooks.Open(strFile)
    
    Dim wsPOR As Worksheet
    Set wsPOR = wbPOR.Sheets(Replace(wbPOR.Name, ".xls", ""))
    
    lastrow = wsPOR.Range("A" & wsPOR.Rows.Count).End(xlUp).Row
    
    wsPOR.Range("A4:N" & lastrow).Copy wbOOR.Sheets("Tel-Nexx Data").Range("A2")
    
    wbPOR.Save
    wbPOR.Close
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need to copy a worksheet from one workbook into another and
I have a workbook which is updated daily and a copy of that workbook
I have an Excel workbook that contains several spreadsheets. I need to pull data
I have a workbook that has many checkboxes (form control) on one tab. I
I have an excel workbook vsto solution that needs to generate a pdf copy
Lets say that I have one component which is doing something with Workbook object
I have a code that loads data from Excel into SQLServer table. It works
I currently have a excel workbook that has values being pulled from other workbooks
I have sales global sales data in very large files which I need to
I have an Excel workbook that I want to use as a template. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.