PDA

View Full Version : [SOLVED] problems with copying the values of one cell to another



major_jls
06-08-2018, 05:47 PM
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

david000
06-08-2018, 06:09 PM
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.

major_jls
06-08-2018, 07:34 PM
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.
22396

22397

22398

david000
06-09-2018, 07:28 AM
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

major_jls
06-09-2018, 08:19 AM
yes it worked. that is what i was needing thank you.