• 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.

Macros Required To Copy Data From One Sheet To Another Work sheet

Techtrend

Member
Macros Required To Copy Data From One Work Sheet To Another Work sheet

Attached are the sample sheet

IN DEC FUT.xlsm Work Book,
In Data Sheet every 15 min we have the data getting saved from a live terminal one below the other.

For ex,

From DEC FUT.xlsm ,Data Sheet complete 37 Row Data will be saved to

DEC_ZSC_LIVE_SHEET.xlsm in Data Sheet in the same Row format one below the other

Can u please let me know if its possible with a macro,need help on code
Hope its clear
Thanks in advance
Satish
 

Attachments

  • DEC_ZSC_LIVE_SHEET.xlsm
    1,004.5 KB · Views: 10
  • DEC FUT.xlsm
    104.2 KB · Views: 9
Last edited:
Stick this (into worksheet code, or a module) into your DEC FUT file:

Code:
Public Sub FileSave()
    'insert procedure to be ran
    'disable screen
    Application.ScreenUpdating = False
    Dim FUT As Workbook
    Dim LiveSheet As Workbook
    Set FUT = ThisWorkbook
    'this opens the live workbook, as per path given (format C:\Users\USERNAME\Desktop\FileMove\DEC_ZSC_LIVE_SHEET.xlsx
    Set LiveSheet = Workbooks.Open("C:\Users\USERNAME\Desktop\FileMove\DEC_ZSC_LIVE_SHEET.xlsx")
    FUT.Sheets("Sheet1").Range("A2:KZ500").Copy
    'determines the last row of the data, pastes copied range in there
    LiveSheet.Sheets("Data").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    LiveSheet.Close True
    FUT.Activate
    'enable screen
    Application.ScreenUpdating = True
    Call Timer
    'restarts the timer
End Sub

Public Sub Timer()
    Application.OnTime Now + TimeValue("00:15:00"), "FileSave"

    'adjust in format of HH:MM:SS for desired time interval
End Sub

Should be a good start.
You will only need to change the location of the livesheet file there in the code (and watch out for the extension). Also might want to insert a line of code to delete your DEC FUT data once it's copied, else you will be copying the same data over again. That'd be something like :
FUT.Range("A2:KZ500").Clear

Right before you enable the screen updating back on

Play around with the timer, I never used that function tbh just googled it.
 
Last edited:
Back
Top