Copying from one sheet to another sheet

thong127

New member
Joined
Jul 20, 2016
Messages
12
Reaction score
0
Points
0
Excel Version(s)
365
Hello All,

Hope all is well. I have an Excel sheet that COnsist of Time & Date and the readings of my 26 sensors (DATA). I want to copy them in to another worksheet.
can you please help me build a formula to copy them to another worksheet.

please find Attached for the data that I need to copy.

Thank you so much in advance.
 

Attachments

  • Auto Copy.xlsx
    268.5 KB · Views: 22
Attached is the format of the data after copying them to a new worksheet.
I need to cut up to sensor IP J3/K2 because its too big to upload but I need to copy them all.


Thank you
 

Attachments

  • copy.xlsx
    395.5 KB · Views: 15
You need a macro for this.
Code:
Sub CopyDataToResultsSheet()
    
    Dim src As Worksheet, dest As Worksheet
    Dim lr As Long, lc As Long, wr As Long, x As Long
    
Set src = Sheets("Data")
Set dest = Sheets("Results")

With src
    lr = .Cells(Rows.Count, "A").End(xlUp).Row
    lc = .Cells(1, Columns.Count).End(xlToLeft).Column
    For x = 2 To lc Step 2
        wr = dest.Range("A" & Rows.Count).End(xlUp).Row + 1
        dest.Range("A" & wr).Resize(lr - 1).Value = .Cells(1, x)
        dest.Range("B" & wr).Resize(lr - 1).Value = .Cells(2, "A").Resize(lr - 1).Value
        dest.Range("C" & wr).Resize(lr - 1).Value = .Cells(2, x).Resize(lr - 1).Value
        dest.Range("D" & wr).Resize(lr - 1).Value = .Cells(2, x + 1).Resize(lr - 1).Value
    Next x
End With

End Sub
 

Attachments

  • Auto_Copy.xlsm
    319.8 KB · Views: 19
@Nos
Do you want your post soft deleted waiting for OP to comply or leave as is?
 
@ Pecoflyer,

Other than preventing others from seeing the post, what would be the point ?

Unless the OP's notifications differ from the ones I get from this forum,
the posted macro was included in the email they got advising of a new reply since they were last logged in.
 
Thanks NoS for saving my LIFE!

How do I mark this as solved?

Thank you.
 
Last edited:
I'm afraid this forum has no "solved" button.
Thanks for adding links and don't forget in the future :smile:
 
helpful macro thanks NoS
 
Back
Top