Forum Discussion
Sue
Dec 05, 2021Copper Contributor
Transferring selected data to a new sheet and checking it is not already transferred
Hi wonderful people! I am selecting lines from a worksheet - these are lines involving donations. I use: With Worksheets("Sheet1").Range("CPData") Set MyEdit = .Find("k", , xlValues, xlWhol...
- Dec 05, 2021
FindNext gets confused if you execute another Find in between the original Find and FindNext.
Change
Set MyEdit = .FindNext(MyEdit)
toSet MyEdit = .Find("k", MyEdit, xlValues, xlWhole, xlByColumns, , True)
HansVogelaar
Dec 05, 2021MVP
FindNext gets confused if you execute another Find in between the original Find and FindNext.
Change
Set MyEdit = .FindNext(MyEdit)
to
Set MyEdit = .Find("k", MyEdit, xlValues, xlWhole, xlByColumns, , True)
Sue
Dec 06, 2021Copper Contributor
Thank you so much! When I read your reply I knew instantly the key word I had missed in my attempts - the second MyEdit in "look after"!!
I had also tried using the full .find again. But I did not realise the default was to search the activecell (which was myEdit) first. I discovered this when the search was "complete" because in this second search the search cell had the "firstaddress". I put in code to move it to the next cell but with the search value always being the same (ie k) and MyEdit being k and the cell below was also k and the active cell both before and after the move being k I became "lost" in a sea of k's! ie thinking of the value of MyEdit instead of the range. When I saw your answer I realized I had moved the cursor (good old days of Lotus123) but NOT the name "MyEdit". I looked up .find and read about .look after. You have not only solved my problem but I have learnt a lot from this event. The "All Donations" works perfectly now although I still need to optimize the code.Thank you again. Sue
I had also tried using the full .find again. But I did not realise the default was to search the activecell (which was myEdit) first. I discovered this when the search was "complete" because in this second search the search cell had the "firstaddress". I put in code to move it to the next cell but with the search value always being the same (ie k) and MyEdit being k and the cell below was also k and the active cell both before and after the move being k I became "lost" in a sea of k's! ie thinking of the value of MyEdit instead of the range. When I saw your answer I realized I had moved the cursor (good old days of Lotus123) but NOT the name "MyEdit". I looked up .find and read about .look after. You have not only solved my problem but I have learnt a lot from this event. The "All Donations" works perfectly now although I still need to optimize the code.Thank you again. Sue