Consulting

Results 1 to 5 of 5

Thread: problems with copying the values of one cell to another

  1. #1

    problems with copying the values of one cell to another

    when i wrote this code on a blank excel sheet it worked fine but when i copied it to the workbook i am needing it on, instead of it moving straight across to the next cell i need it to go to it moves over and down 6 rows and all the code is the same except for what columns i am using.

    do you see anything wrong with this code

    sub copy&pastecolumn()

    Dim erow As Long
    Worksheets("sheet1").Select


    erow = ActiveSheet.Cells(1, 1).CurrentRegion.Rows.Count + 1
    Worksheets("sheet1").Select
    Worksheets("sheet1").Range("G2").Select

    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy Sheets("sheet1").Cells(erow, 6)

    End Sub

  2. #2
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location
    Can you post a sample of the workbook you are working on and the desired results? For now, the line:

    erow = ActiveSheet.Cells(1, 1).CurrentRegion.Rows.Count + 1
    doesn't seem to be giving you the correct number of rows you want.
    "To a man with a hammer everything looks like a nail." - Mark Twain

  3. #3
    so the Clear Beg read button works fine all it does is clear the values of Cell E.

    when i Click the Move End Read to Beg. Read button is when it screws up it moves the cells over like it is supposed but it also moves 7 rows down
    and it also deletes the previous values that it copied and that part works fine.
    excel problems.jpg

    excel problems.1.jpg

    excel problems.2.jpg

  4. #4
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location
    Move End Read to Beg
    If you're just trying to move 'End' in this case column F to 'Beg' column E then this should work.
    Sub Move_F_To_E()
    With Sheet1
        .Range("f2").Resize(.Cells(.Rows.Count, "f").End(xlUp).Row - 1).copy .Range("e2")
    End With
    Application.CutCopyMode = False
    End Sub


    The sample code you posted is selecting column 7 or G and copying that over to column 6 or F
    Worksheets("sheet1").Range("G2").Select 'Column 7 (G)
    Range(Selection, Selection.End(xlDown)).Select
    Selection.copy Sheets("sheet1").Cells(erow, 6) 'This is copying G to F
    "To a man with a hammer everything looks like a nail." - Mark Twain

  5. #5
    yes it worked. that is what i was needing thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •