+ Reply to Thread
Results 1 to 7 of 7

how do I copy data (not fixed) from one sheet to the first empty cell of col A of another

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    how do I copy data (not fixed) from one sheet to the first empty cell of col A of another

    I have a project where I want to copy data that is across 4 columns and an always changing number of rows over to the first empty cell in column A of another sheet.
    The data to be copied could be 300 rows long and is always 4 rows wide.

    I've come up with an autofilter to filter out the 0s and delete the rows with 0s and now I'm stuck here.

    Ultimately I'd like to be able to filter out the rows with 0s in the hours column and paste other rows to the first empty cell in column A.

    Any help is appreciated. I've scrounged google and these forums for hours over the past several days and have not found one that does the trick.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    Upload a sample workbook with no sensitive data showing how the data structure. Without seeing how the data is formed and where the hours column is it is very difficult to help you. If the column with is 4 and variable row length you can find dynamic row number easily however a sample workbook would help.
    Last edited by smuzoen; 12-27-2012 at 07:38 PM.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    This is the latest code I'm trying.

    Sub copytoactualtime()
    Sheets("actualtransfer2").Range("A2:D300").Copy
    Sheets("ActualTime").Activate
    Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Select

    ActiveCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 49407
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With

    End Sub


    I will post a sample of the pages once I dumb it down some.

  4. #4
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    I'd like to copy the data in sheet actualtransfer2 into actual time.
    The code would look for the next empty cell in actual time and then paste the info from actualtransfer2.
    I'd prefer a code that dynamically changes to the number of rows in actualtransfer2. Rightnow I have locked it into a range.
    Any help is appreciated. Thanks.sampletoforum.xls

  5. #5
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    I actually got it to work last night but now it no longer works.
    Any ideas why this would happen?

  6. #6
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    I have finally figured out the solution but now am into a stickier situation.

    The solution is in the code below. You basically have to start from the bottom of the sheet and xlup until you find a value in the column A then offset down. This way is the foolproof way.
    The way most people would recommend, using xldown until you find the bottom of the column tends to error if you have no value in A2. Which I do not currently as this spreadsheet is not yet populated.

    The question I have is in the bolded section. I need to copy a current region minus the top header row from one worksheet to another. Then in this other worksheet it will provide a fill color for the new info.
    I think I need to split this up somehow but I do not have the VBA skills to do so. I basically compile various macros and mash them together which I know is not the best but it's the best I can do.
    Any help is appreciated.

    Sub ActualTimeAllInOne()

    Sheets("actualtransfer2").Activate
    Cells.Select
    Selection.Clear
    Sheets("actualtransfer1").Select
    Range("A1:D1").Select
    Selection.Copy
    Sheets("actualtransfer2").Select
    Range("A1").Select
    ActiveSheet.Paste
    Sheets("actualtransfer1").Range("A1:D300").AdvancedFilter Action:= _
    xlFilterCopy, CriteriaRange:=Sheets("actualtransfer1").Range("F1:F2"), _
    CopyToRange:=Range("actualtransfer2!Extract"), Unique:=False

    Sheets("actualtime").Activate
    Cells.Select
    With Selection.Interior
    .Pattern = xlNone
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With


    Sheets("actualtransfer2").Activate
    ActiveSheet.Range("a2", _
    ActiveSheet.Range("a1").End(xlDown).End(xlToRight)).Copy


    Sheets("actualtime").Activate
    Range("A65536").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select

    ActiveCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 49407
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With

    Sheets("Actual Time Input").Activate
    Range("A2").Select
    Selection.ClearContents
    Range("A8:AD17").Select
    Selection.ClearContents

    End Sub

  7. #7
    Registered User
    Join Date
    12-26-2012
    Location
    cary,NC
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: how do I copy data (not fixed) from one sheet to the first empty cell of col A of anot

    I just wanted to post that I found a way to fix the issues I had and it's working now.

    Sub ActualTimeAllInOne()

    Sheets("actualtransfer2").Activate
    Cells.Select
    Selection.Clear
    Sheets("actualtransfer1").Select
    Range("A1:D1").Select
    Selection.Copy
    Sheets("actualtransfer2").Select
    Range("A1").Select
    ActiveSheet.Paste
    Sheets("actualtransfer1").Range("A1:D300").AdvancedFilter Action:= _
    xlFilterCopy, CriteriaRange:=Sheets("actualtransfer1").Range("F1:F2"), _
    CopyToRange:=Range("actualtransfer2!Extract"), Unique:=False

    Sheets("actualtime").Activate
    Cells.Select
    With Selection.Interior
    .Pattern = xlNone
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With

    Sheets("actualtime").Activate
    Range("A65536").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select

    Sheets("actualtransfer2").Activate
    ActiveSheet.Range("a2", _
    ActiveSheet.Range("a1").End(xlDown).End(xlToRight)).Copy

    Sheets("actualtime").Activate
    ActiveCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 49407
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With

    ' Sheets("Actual Time Input").Activate
    ' Range("A2").Select
    ' Selection.ClearContents
    'Range("A8:AD17").Select
    'Selection.ClearContents

    End Sub

+ 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