Closed Thread
Results 1 to 2 of 2

copy values in different worksheet in one single worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-11-2011
    Location
    Freiburg, Germany
    MS-Off Ver
    Excel 2003
    Posts
    3

    Question copy values in different worksheet in one single worksheet

    Hell everybody, I need help to fix the problem. I hope that somebody could solve the small problem.

    The first part import the columns of the selected *.csv files in different worksheet. The second part copy the columns of each worksheet in the same worksheet but in the SAME column. I would have only the 2nd column of each worksheet in different colmuns in the worksheet.

    Option Explicit
    Sub importCSV()
    Dim oeffnen, n As Integer
    Application.ScreenUpdating = False
    oeffnen = Application _
    .GetOpenFilename(fileFilter:="Text Files (*.csv), *.csv", MultiSelect:=True)
    If IsArray(oeffnen) = False Then GoTo ENDE
    For n = 1 To UBound(oeffnen)
    Workbooks.OpenText oeffnen(n)
    ActiveWorkbook.Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
    Workbooks(Mid(oeffnen(n), InStrRev(oeffnen(n), "\") + 1)).Close False
    Next n
    ENDE:
    Application.ScreenUpdating = True
    
    Dim J As Integer
    
    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add ' add a sheet in first place
    Sheets(1).Name = "Combined"
    
    ' copy headings
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    
    ' work through sheets
    For J = 2 To Sheets.Count ' from sheet 2 to last sheet
    Sheets(J).Activate ' make the sheet active
    Range("A1").Select
    Selection.CurrentRegion.Select ' select all cells in this sheets
    
    ' copy cells selected in the new sheet on last line
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub
    Thank you in advance

    Alberto Steffani

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: copy values in different worksheet in one single worksheet

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1