Move data from on column to another

lucas50nj

New Member
Joined
Jun 13, 2018
Messages
9
Hello,
I am new to macros and this may be a simple question, hope you can help. PLEASE!! Thanks!

I'm trying to search for any string with a ":" from column M and move it to column D but start at a specific row based on a search i have. For example:

This finds kis emr and returns the row.

Dim rngSearch As Range, rngFound As Range
Set rngSearch = Range("a:a")
Set rngFound = rngSearch.Find(What:="kis emr", LookIn:=xlValues, LookAt:=xlPart)

This finds the ":" and moves it to the row found above but the problem is that when it finds every occurrence of ":" it overwrites the previous move. I need it to increment a row down before it finds the next ":" and move it.

If Range("m" & row).Value Like "*:*" Then 'if found then move it to d column

Range("d" & rngFound.row).Value = Range("m" & row).Value
'Range("d" & row).Value = Range("m" & row).Value
Range("m" & row).Value = ""

End if
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi & welcome to the board.

How about
Code:
Sub FndCopy()
Dim Fnd As Range, Fnd2 As Range
Dim Qty As Long, i As Long

Set Fnd2 = Range("M1")
Set Fnd = Range("A:A").Find("kis emr", , xlValues, xlPart, , , , , False)
Qty = Application.CountIf(Range("M:M"), "*:*")
For i = 1 To Qty
   Set Fnd2 = Range("M:M").Find(":", Fnd2, , xlPart, , , , , False)
   Fnd.Offset(i - 1, 3).Value = Fnd2.Offset(, -9)
Next i
End Sub
 
Upvote 0
Hi Fluff, thank you for your response and welcome.
Your code does locate the items with a : but can you tell me how to move it to column d row number which is labeled KIS EMR in column A? Also please let me know once it writes the first one with a : then move down to cell below so it won't overwrite it?
 
Upvote 0
Thank you Forever_EX,
I am familiar with the findnext and tried it but does not work for me. I will look at the link you sent to see if I can use anything there.
Thanks!!!
 
Upvote 0
but can you tell me how to move it to column d row number which is labeled KIS EMR in column A? Also please let me know once it writes the first one with a : then move down to cell below so it won't overwrite it?
My code should already do that. If it's not can you please let me know what it is doing?
 
Last edited:
Upvote 0
Fluff,
I'm trying to do a simple find with anything with a : (ex. Weekly: , Monthly: or Ongoing:. Once I find this then I copy whatever pertains to these into another cell (E).
So this is after my macro finds the cells with a : in column M and moves it to column D after is locates KIS EMR on column A.

[TABLE="width: 722"]
<tbody>[TR]
[TD="class: xl63, width: 137"]KIS EMR[/TD]
[TD="class: xl63, width: 137"]Application Development[/TD]
[TD="class: xl63, width: 137"]Susan Kistler[/TD]
[TD="width: 174"]Ongoing:[/TD]
[TD="class: xl66, width: 137"]5/23/18 Activated the monitor account for Marlene. Monitor here 5/23. [/TD]
[/TR]
</tbody>[/TABLE]

The column where it says Ongoing came from col M and the one starting with 5/23 also came from column M which is the content for Ongoing. My problem is when my macro reads and finds the : ( ie weekly: and Monthly:) first, it sees weekly first copies over than it finds monthly copies that over and lastly finds ongoing and copies that over. monthly overwrites weekly and ongoing overwrites monthly. I need it to go down a cell so it does not overwrite. Hope this is clearer.
Thanks for your help!!!
 
Upvote 0
My code should not be overwriting the previous value, but for some reason I had it copy the value from col D not col M. It should be
Code:
For i = 1 To Qty
   Set Fnd2 = Range("M:M").Find(":", Fnd2, , xlPart, , , , , False)
   Fnd.Offset(i - 1, 3).Value = [COLOR=#ff0000]Fnd2.Value[/COLOR]
Next i
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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