Hi Everyone
I want to use a piece of VBA to copy values from cells A1, C1, E1, and G1 and paste them into the next blank cell in an existing range called "DCopy". I am trying to use the following code, but as I have never tried writing a looping macro, have no idea what I am doing:
If I fire the macro above, it copies the cells, but pastes them into every cell in the "DCopy" range.Dim FirstCell As Range Dim FirstTargetCell As Range Dim i As Integer Set FirstCell = Sheets("Sheet1").Range("DEntry") Set FirstTargetCell = Sheets("Sheet1").Range("DCopy") i = 0 Do FirstTargetCell.Offset(i, 0).Value = FirstCell.Offset(i, 0).Value i = i + 1 Loop Until FirstCell.Offset(i, 0).Value = ""
Basically, I am trying to build a catalog, and want to enter the data in to the "DEntry" range, and have it copied to the next free line in the "DCopy" range.
Does anyone have any ideas?
Last edited by jiminic; 10-06-2008 at 07:13 PM.
You don't need a loop to do this. I can't see how your ode is finding the empty cell. Where is Dcopy? This will be more efficient & faster, you will have to amend the destination cells
Dim R As Long R = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row + 1 Cells(R, 1).Value = Cells(1, 1).Value Cells(R, 2).Value = Cells(1, 3).Value Cells(R, 3).Value = Cells(1, 5).Value Cells(R, 4).Value = Cells(1, 7).Value
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks RoyUK, as usual you have saved my day!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks