+ Reply to Thread
Results 1 to 3 of 3

Code to copy from worksheet to another

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    Chambersburg, PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    Code to copy from worksheet to another

    I have a sheet we are developing to do some simple time tracking. We want to enter on one sheet then basicly archive to another for some analysis later. I have a code from and older sheet that copies certain cells from one sheet to the next. It's very crude but works. I need to copy many more than my current code allows and I'm not sure even how to begin to do that. I had an idea of how but when i got into it more i ended up with 200 plus lines of copied code which sent my sheet into oblivion. So I'm appealing to the masses for someone to guide be in a much better direction. I've attached a sample of the sheet for reference. The main idea being we imput on the time sheet then run code to export and store on the collection sheet. Many thanks in advance!

    Old code I used was:
    Sub copy_data()
    
    Run "Doit"
    Application.ScreenUpdating = False
    
    If Worksheets("Entry").Range("E2") = "" Then
        
        MsgBox ("No Name entered"), vbCritical
        Exit Sub
    
    Else
    
        lastrowA = Worksheets("Percentage By Operator").Range("A4").End(xlDown).Row
        
        Worksheets("Percentage By Operator").Range("A" & lastrowA + 1).Value = Worksheets("Entry").Range("E2").Value
        Worksheets("Percentage By Operator").Range("B" & lastrowA + 1).Value = Worksheets("Entry").Range("G2").Value
        Worksheets("Percentage By Operator").Range("C" & lastrowA + 1).Value = Worksheets("Entry").Range("H2").Value
        Worksheets("Percentage By Operator").Range("D" & lastrowA + 1).Value = Worksheets("Entry").Range("I2").Value
        Worksheets("Percentage By Operator").Range("E" & lastrowA + 1).Value = Worksheets("Entry").Range("I20").Value
        Worksheets("Percentage By Operator").Range("F" & lastrowA + 1).Value = Worksheets("Entry").Range("I21").Value
        Worksheets("Percentage By Operator").Range("G" & lastrowA + 1).Value = Worksheets("Entry").Range("I27").Value
        Worksheets("Percentage By Operator").Range("H" & lastrowA + 1).Value = Worksheets("Entry").Range("I22").Value
       MsgBox ("          Export Complete          "), vbOKOnly
        
        lastrow = Worksheets("Entry").Range("B6").End(xlDown).Row
        
    End If
    Run "Doit"
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Code to copy from worksheet to another

    hi Oly Steel Man, please check attachment
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-28-2010
    Location
    Chambersburg, PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Code to copy from worksheet to another

    @ watersev

    Seems to work well, thanks! I'll continue to test it with random samples of data. Very appreciative of the input!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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