Copy and Paste Macro?

OpenIntro

New Member
Joined
Jul 22, 2003
Messages
37
Let me explain what I am trying to do.

I have an Excel Spreadsheet that is being used to input a lot of data. Quite a bit of the information is the same each time I start a new row of data. I am looking for a way to automate this, so that certain columns already have the "same" information filled in upon the click of a button. Specifically, each time I click the button, I would like a certain 4 rows of data to be pasted in to the next empty row. So if I have data through row 4500, I want the rows to appear from 4501-4504.

The problem I am running into is how do I set up a macro that will paste into the next EMPTY row? I assume using some kind of count function, but not totally sure. Any ideas?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
specifically, which certain columns do you want to be copied down? do they contain formulas? this can easily be done, but need a little more information

thanks,
kevin
 
Upvote 0
This will take you to the next empty row starting from the active cell - It assumes that you have contighuous rows of data. (Credit to John Walkenbach):

Sub ActivateNextBlankDown()
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
End Sub

Hope that helps,

Smitty
 
Upvote 0
Hi OpenIntro:

Welcome to the Board!

If I have understood you correctly, you may find the following illustration of some interest ...
Book1
ABCDEFGHI
44851
44861a
44872b
44883c
44894d
44905
44916
44927copyRange
44938PasteToCell
44949
449510
449611
449712
449813
449914
450015
4501a
4502b
4503c
4504d
Sheet2


The Aqua colored cells represent the copyRange, and the Brown colored cell represents to PasteToCell -- then the following code should do what you are intending to do ...
Code:
Sub yCopyRangeAndPasteToFirstEmptyRowinColumnA()
    Set PasteTocell = [a1].End(xlDown)(2)
    Range("copyRange").Copy PasteTocell
End Sub
I hope this helps. If I have misunderstood your question -- my apologies!
 
Upvote 0
Thank you all for your replies. I apologize for it taking so long for me to reply back!

Yogi, I think that your interpretation is the closest to what I am looking for.

I have 4 rows (and multiple columns) of data that I want pasted in the NEXT empty rows upon the click of a button.

I am not sure what I am supposed to do with the brown and aqua colored cells? I am guessing I can "hide" the information that want copied and pasted on ANOTHER sheet, but I have not figured out how to work this into the macro.

Any other suggestions?
 
Upvote 0
Hi OpenIntro:

The brown colored cell is part of the range that has been copied. The color coding is simply to see what is being copied where. I do not see any problem there -- do you? Please post back with some specifics if you need to discuss this further.
 
Upvote 0
In your example though, in C4492 there is a brown cell and C4493 an aqua cell. Am I supposed to put something in these cells? Because the only thing being copied and pasted is C4486-C4489.

I guess I don't understand in the macro that you created, what the "copyRange" and "PasteToCell" parts do and what I need to change?
 
Upvote 0
OpenIntro said:
In your example though, in C4492 there is a brown cell and C4493 an aqua cell. Am I supposed to put something in these cells? Because the only thing being copied and pasted is C4486-C4489.

I guess I don't understand in the macro that you created, what the "copyRange" and "PasteToCell" parts do and what I need to change?

Define the range C4486:4489 as CopyRange; cells C4492 and C4493 were used just to show you the color legend -- nothing has to be done to those cells.

I hope this helps.
 
Upvote 0
select the range C4486:C4489, then go to the insert menu, select names, define, type CopyRange as your range name, and click OK

hth
kevin
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,061
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top