Macro to add text to cell

A

akemeny

Hi,

I browsed through all the other posts before posting this. I was hoping it
would be a easy macro, but it doesn't appear to be so I thank anyone that
helps in advance.

What I need is a Macro that will do the following:

1. Look at the data in each cell of Range X6:x361
2. Find "IP/OP Obs"
3. Enter "No IP acuity documented; should have been OP Observation" into the
corresponding cell for that row in column BK

And I need it to loop continuously. In addition I need to prevent the macro
from giving me an error when it comes to a blank cell.
 
M

Mike H

Hi,

Right click your sheet tab, view code and paste the code below in and run
it. Running it all the time isn't practical but you could run it every n
seconds/minutes and to do this have a look at ontime here.

http://www.ozgrid.com/Excel/run-macro-on-time.htm

Sub Sonic()
For Each c In Range("X6:X361")
If c.Value = "IP/OP Obs" Then
c.Offset(, 39).Value = "No IP acuity documented; should have been OP
Observation"
End If
Next
End Sub


Mike
 
T

The Code Cage Team

I haven't had time to test this but this should do the trick:

Sub find_n_replace()
Dim Rng As Range, MyCell As Range
Set Rng = ActiveSheet.Range("X6:X361")
For Each MyCell In Rng
If MyCell.Value = "IP/OP Obs" Then
ActiveSheet.Range("BK" & MyCell.Row).Value = _
"No IP acuity documented; should have been OP Observation"
End If
activesheets.Columns("BK").AutoFit
End Su

--
The Code Cage Tea

Regards,
The Code Cage Team
www.thecodecage.co
 
T

The Code Cage Team

Sorry i forgot the "Next" off the code!

Sub find_n_replace()
Dim Rng As Range, MyCell As Range
Set Rng = ActiveSheet.Range("X6:X361")
For Each MyCell In Rng
If MyCell.Value = "IP/OP Obs" Then
ActiveSheet.Range("BK" & MyCell.Row).Value = _
"No IP acuity documented; should have been OP Observation"
End If
Next MyCell
activesheet.Columns("BK").AutoFit
End Su

--
The Code Cage Tea

Regards,
The Code Cage Team
www.thecodecage.co
 
Top