How to Write VBA Macros to Copy and Paste Cells in Excel - Part 1 of 3

preview_player
Показать описание

Learn how to copy and paste cells and ranges in Excel with VBA. This video tutorial is the first in a 3 part video series that explains the Range.Copy method. This is any easy way write a macro for a simple copy and paste in Excel.
Рекомендации по теме
Комментарии
Автор

OMG I have been a programmer for centuries and written so many Excel macros.
Today I hit problems with Cut and Paste and could not understand why!
Looking for a solution, I found this wonderful article and saw the range.copy to destination syntax for the first time!
Thousands of copy and paste were unnecessary if only I had known!

Working from home is not all it is cracked up to be. Thank you so much Jon.

You probably know why my macro was failing! I discovered that whenever I selected a cell or sheet or anything, the address was automatically entered into my cut/paste buffer? I was cutting from one sheet to another, so I was always go to have a select between Cut and Paste to destroy Synchronisation on my intended cut and paste?

Once that problem is solved it will be interesting to see if the range.copy still works? Synchronisation is guaranteed there if the the data is buffered at all.

mikepike
Автор

This Works for me now -
Sub CopyToBook()
Set y = Workbooks.Open("Path to the
End Sub

manasimahajan
Автор

You're a Rockstar! I went from zero to being able to write the macros I needed in a minute thanks to this. Cheers :-)

Doc
Автор

Awesome, didn't realise this stuff was so simple. You Rock Dude !!!

JayDubster
Автор

Really really helpful, this way I reduced 30 % of lines in my codes. Thanks!

jeetsingh
Автор

This is so useful! Thank you very much!

stephanie_ong
Автор

Hi, what if I want to copy and paste it to an active cell(that i will basically and manually choose the paste destination on the time that i am doing a task). Actually, i will need a button for POS system. Thanl you so much.

alvismacalintal
Автор

Just wondering if you can paste data into a cell which is merged ?

I want to also keep the formatting of the merged cell which has justification/ font / size / cell colour.
The data I want to paste should inherit the merged cell formatting

guyjinpop
Автор

Hi Jon, how to copy data from one cell and paste into another merged cell in vba ?

syedshahzaibali
Автор

I'm creating a report at work and have this working, but I'm needing to insert the column in between others. The way this is working is pasting over a cell that I already have used. What would I need to do different?

atlsoldier
Автор

Thank you so much for this incredibly helpful tutorial!!

jiayuezhan
Автор

Great videos - definitely worth watching if you are interested in getting started with VBA

jacquedreyer
Автор

Awesome. How about if I want to copy a non blank is a range? Say Cell A1 - A10 then I want all non blank copied to cell. Thanks.

hbl_channel
Автор

I cannot copy between two separate workbooks. I have a comment "Syntax error". Something must have been wrong in this code. Please take a look again on the last one.

mariuszkrukar
Автор

thank you for the lesson. i have a question, i have 80 sheets, how can apply this code to all my sheets at once. thank you again.

abdulhamidalhaddadi
Автор

How do you execute END-DOWN and copy at the cell on lands then tell it to move right and paste . I want to use this macro at numerous locations without referencing the new destination since it will change every time?

herodog
Автор

How can I run this sequence on Marco?
1. Cut text in B105. Paste in G104
2. Move two rows down
3. Cut text in B107. Paste in G106
4. Move two rows down
5. Cut text in B109. Paste in G108
6. Run till end of worksheet

oladiranotegbade
Автор

I have excell sheet where in column D i need to restrict the characters limitations to 40 only when copy and paste some data from any excel sheet in any cell in this column also when typing in same column more than 40 characters a pop up warning msg displayed and prevent the paste action as well as preventing the typing action

maxact
Автор

very clear, very helpful .. thanks so much Jon .. btw, i just have a question .. my cells are using links from another tab. I just want to overwrite those links with Paste/Value ... within the same workbook (not from a different workbook) .. is there a smart way to do it (read the From cells, copy to the To cells (in place), since they're are actually the same cells) ? do i still have to write out the whole command you showed above .. provide the "FromCell.Copy ToCell " (wsCopy.Range("A2:A9").Copy wsDest.Range("A2:A9") ??

TheSnowmanvn
Автор

Thanks friend. Please I need to copy specific cell "A2" and past it repeatedly as per used row count. suppose in another sheet I have used 10 row "B1:F10", so I need to repeat it in "A1:A10". But the last row unknown. could you help me please?

mohammedabdulghany