Results 1 to 4 of 4

Cells format change after copy and paste data

Threaded View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Cells format change after copy and paste data

    Hi

    I'm going creazy, because when SAP export to excel file, I don't know why, the file is created with the extension XLS

    I need copy data in One tab("cobaia") from file "cobaia.XLS" and paste into file "PasteHere.xlsm"

    When I copy data by VBA, something wrong happening, if you look in columns(T,W,X,Y,Z,AA,AC,AD,AE,AF,AG,AI,AJ,AK,AL,AN,AO,AP), the value came with "error" (spaces, not number)

    I'm using this code below.
    Sub Stole_this_Code_from_davesexcel()
    'http://www.excelforum.com/excel-programming-vba-macros/1063028-copy-related-cells-from-different-workbooks-to-same-workbook.html
    'Sorry I stole this code from davesexcel
        Dim MyFile As String, Str As String, MyDir As String, Wb As Workbook
        Dim Rws As Long, Rng As Range
        Set Wb = ThisWorkbook
        'change the address to suite
        MyDir = "C:\Users\monica\Downloads\Monica\"
        MyFile = Dir(MyDir & "cobaia.XLS")    'change file extension
        ChDir MyDir
        Application.ScreenUpdating = 0
        Application.DisplayAlerts = 0
    
        Do While MyFile <> ""
            Workbooks.Open (MyFile)
            With Worksheets("cobaia")
                Rws = .Cells(Rows.Count, "C").End(xlUp).Row
                Set Rng = Range(.Cells(1, 1), .Cells(Rws, 44))
                Rng.Copy Wb.Worksheets("Relatorio").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
                ActiveWorkbook.Close True
            End With
            MyFile = Dir()
        Loop
    
    End Sub
    My files size 72Mb, because this, I paste files on GoogleDrive:
    https://drive.google.com/drive/folde...fE?usp=sharing

    Thank you!!
    Last edited by marreco; 05-06-2019 at 03:27 PM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. copy abbreviated format add a , add a cells value and paste to only blank cells
    By kleptilian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2014, 02:26 PM
  2. Replies: 1
    Last Post: 01-16-2013, 05:36 AM
  3. Copy Format and paste to range of cells
    By Longpod in forum Excel General
    Replies: 4
    Last Post: 06-27-2012, 02:22 AM
  4. [SOLVED] Copy data in one format from Sheet1 and paste to another sheet in another format.
    By FergusC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2012, 08:36 PM
  5. Can you change the format of copy/paste?
    By noidea in forum Excel General
    Replies: 3
    Last Post: 08-04-2007, 10:02 PM
  6. [SOLVED] copy & paste and change format
    By SLB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2006, 08:29 AM
  7. Lock Cell Format - Allow copy and paste of data without format change
    By Chris12InKC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-11-2006, 12:50 AM

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