copying rows, w/o knowing row number

thexfactor44

New Member
Joined
Feb 21, 2002
Messages
26
I am using FIND in a macro to find any occurance of "name" in Column C of Sheet1. If FIND locates the given "name", I want to copy that row and paste it in the first available row of the neighboring sheet, in this case Sheet2. In this application, the first available row is Row 5 on Sheet2.

This is the main function of the macro. the rest could be called repetition, as I would like to be able to FIND all occurances of "name" on sheet1 and copy the entire row into Sheet2, but the next line to be pasted would obviously have to be Row 6 of Sheet2 as to not overwrite.

I have tried, and I do not know how to select the row N, where N is the number in Column C that "name" was found, and I am also having issues getting XL to paste starting with Row 5 on Sheet 2 and incrimenting. Also, FIND only seems to find it once, how do I get it to repeat throughout?

Thanks to all on this one, I know it is long, trying to be descriptive.
 
I don't know about the Run Time Error, but the ActiveCell.R1C1 is something i just learned about from a prior program i did, and i just copied it from some existing code, it worked for my purposes, but i guess not for yours. Why? I do not know:)

Also, something i noticed on the original code i posted, which is a BIG errror!!

When using For Count=1 to 100 and then then next line is Count=Count + 1...

This leads to reading only every other cell, as the line "Next Count" automatically increased the value of Count by 1, and then the line Count=Count+1 adds another 1 to it, so the previous code was really only reading every other line, and not every line.

How'd the "newer" code work out for you (if you've tried it yet).

PS- i also just noticed i didn't take out the MsgBox line, which i used for testing purposes... i'll go back and edit the original post
This message was edited by thereuare on 2002-09-05 17:13
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Okay, so I pasted in the new code and commented out the part about message box as it seemed more of a runtime debug tool...

It works!

so thanks for the help. I really appreciate it.

I thought I had to ask for one modification for it, but now that I am writing this, I see I can make the starting value of PasteRow anything I want it to be, thus creating the offset of the first 4 rows.

So thanks again. I really appreciate your help. This message board seems to be very active and intuitive even when working with a monkey like myself.
 
Upvote 0

Forum statistics

Threads
1,215,700
Messages
6,126,302
Members
449,308
Latest member
VerifiedBleachersAttendee

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