View Full Version : How to post predefined cell value to active cell
levvosk
01-26-2022, 04:50 PM
I am a newbie in VBA Excel.
Let's say, I have to take the value of cell A1 and paste it to the active cell in the SAME column.
So, copy cell A1 with value 123 to the active cell A10.
Sounds easy? Please help.
arnelgp
01-26-2022, 08:14 PM
without VBA, you can just copy/paste the value from A1 to A10.
or add a formula in A10:
=A1
with VBA, just Record a Macro.
levvosk
01-26-2022, 08:32 PM
I am a newbie in VBA Excel.
Let's say, I have to take the value of cell A1 and paste it to the active cell in the SAME column.
So, copy cell A1 with value 123 to the active cell A10.
Sounds easy? Please help.
I maybe did not explain the task very well. I am looking for copy/paste automation. I need to paste the value from the top row cell to the same column cell below by activating this cell and hitting the shortcut key. In my mind, it should be a macro with custom VBA code inside.
Thank you in advance.
arnelgp
01-26-2022, 09:04 PM
that's what i said,
Record a macro.
copy and paste the cells.
Save the macro.
if you go to VBA you will see that it created a Public sub with VBA code in it.
you only need to Edit the macro to Always copy from the Top cell.
levvosk
01-26-2022, 09:16 PM
"Edit the macro to Always copy from the Top cell" - it's my problem. I need to have the same logic for all 100 other columns.
Aussiebear
01-27-2022, 03:37 AM
Sub Macro1()
' Copy and Paste row
'Range("A1:CW1").Copy
Range("A10").Paste
End Sub
georgiboy
01-27-2022, 04:20 AM
For something like this you may not even need copy/ paste
Sub MoveVal()
Range("A10").Value = Range("A1").Value
End Sub
Paul_Hossler
01-27-2022, 05:53 AM
"Edit the macro to Always copy from the Top cell" - it's my problem. I need to have the same logic for all 100 other columns.
That's why it's important to provide all information and maybe even a sample workbook
Option Explicit
Sub Something()
Range(Range("A1"), Range("A1").End(xlToRight)).Copy Cells(ActiveCell.Row, 1)
End Sub
levvosk
01-28-2022, 07:33 AM
Hi Paul,
It's worked! The thing is it's copying the entire top row to the active row/cells. I just looking for a copy one cell at a time from the top row cell.
Thank you!
Paul_Hossler
01-28-2022, 09:24 AM
Guess I misunderstood:
I need to have the same logic for all 100 other columns.
Option Explicit
Sub Something1()
Cells(1, ActiveCell.Column).Copy ActiveCell
End Sub
If that is still not it, then you'll have to come up a very detailed example workbook
levvosk
01-28-2022, 09:53 AM
You got it! Very elegant!
THANK YOU VERY MUCH! I REALLY APPRECIATE IT!
Paul_Hossler
01-28-2022, 12:31 PM
Glad it works
You can mark it [SOLVED] using #3 in my signature
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.