• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy data from blank (after insert manualy data inside) to saved file

marreco

Member
HI

imagine that you have a aplicaticação that exports the data without saving an excel file.

then the exported file is opened on the screen.

how to copy the data from that file open (not saved) to a file (open) already saved?


the problem is that this file does not yet have a name (default name when a file is opened blank, it would be book1), but I can not choose this file, because it does not have an extension (xls, xlsx etc), this because he has not been saved.

Code:
Sub Copy_From_NotSavedFile_To_SavedFile()
'I need get data in column A from not seved file to saved file
    ActiveWorkbook.Sheets(1).Range("A2:A100").Copy Destination:=ThisWorkbook.Sheets("SavedTab").Range("A1")
End Sub

Thank you!!
 
Hi marreco,

Does your posted code not work? Since it doesn't use the file names, I would think it would. :(
 
Check this...

Code:
Sub CopyPasteInClosed()
Dim copy_rng As Range, myOutput As Workbook

Application.ScreenUpdating = False

Set copy_rng = ThisWorkbook.ActiveSheet.Range("A2:A100")
Set myOutput = Workbooks.Open("C:\Users\dEEPAK\Desktop\count.xlsx") 'where to saved

copy_rng.Copy
myOutput.Sheets("SavedTab").Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

myOutput.Close 1

MsgBox "Data Saved!!"

Application.ScreenUpdating = True

End Sub
 
Hello Sir..

I have a logic to workout but I do not have a code handy.. Try incorporating it and let me know..

Before opening the exported workbook try to get the count of open workbooks and once the exported workbook is opened your workbook index would be increased by one so you could use this to activate the last opened workbook and possibly your code would be fine to get the data copied and pasted..
 
Hello Sir..

I have a logic to workout but I do not have a code handy.. Try incorporating it and let me know..

Before opening the exported workbook try to get the count of open workbooks and once the exported workbook is opened your workbook index would be increased by one so you could use this to activate the last opened workbook and possibly your code would be fine to get the data copied and pasted..

You mean to say that data will saved on latest workbook.
 
Deepak Sir,

Data will be copied from the last opened workbook (Exported file) to the raw workbook (where the codes are written).. by using
Code:
ActiveWorkbook.Sheets(1).Range("A2:A100").Copy Destination:=ThisWorkbook
 
Save this in so called raw workbook

Code:
Sub CopyPaste()

Application.ScreenUpdating = False

ActiveSheet.Range("A2:A100").Copy
ThisWorkbook.Sheets("SavedTab").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode = False

MsgBox "Data Saved!!"

Application.ScreenUpdating = True
End Sub

& Call it from activesheet (Exported file).
 
My english is bad, but i try explain...

imagine...
FileSave.xlxm
Now you open a blank file inside this new blank file you add data in column A.

how get data in new blank file using your FileSave.xlxm ?
 
imagine...
FileSave.xlxm
Now you open a blank file inside this new blank file you add data in column A.

how get data in new blank file using your FileSave.xlxm ?

It is xlsm not xlxm

Check this..

Code:
Option Explicit

Sub CopyPasteInOpen()
Dim myCopyRange As Workbook, myPasteRange As Range

Application.ScreenUpdating = False

Set myCopyRange = Workbooks("FileSave").Sheets(1).Range("A2:A100")
Set myPasteRange = ThisWorkbook.Sheets("SavedTab").Range("A1")

myCopyRange.Copy
myPasteRange.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Application.ScreenUpdating = True

End Sub
 
Back
Top