Macro to Insert text in a cell based on a condition.

kshitij_dch

Active Member
Joined
Apr 1, 2012
Messages
362
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
Hi all,

I have a excel sheet , In J column i have 'Policy Type' , In AK Column I have 'Final Status'.

I am looking for a macro code that can search 'Renew' in Column J (Policy Type) , Against all Renew in Column AK , it should insert 'To be Defined'.

[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Policy Type (J Column)[/TD]
[TD]Final Status (AK Column)[/TD]
[/TR]
[TR]
[TD]New [/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Renew[/TD]
[TD]To be Defined[/TD]
[/TR]
</tbody>[/TABLE]
anticipate a response :D
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Thank you for a quick reply Mikerickson , actually this is a macro enabled file and i have few codes already running in the file.

I am looking to add a code in same module , otherwise macro code will overwrite the formula ends in no result.
 
Upvote 0
If column "J" has "Renew" you want "To Be Defined in column "AK"

Try this:
Code:
Sub Renew_Yes()
Application.ScreenUpdating = False
Dim c As Range
    For Each c In Range("J1:J" & Cells(Rows.Count, "J").End(xlUp).Row)
        If c.Value = "Renew" Then c.Offset(, 27).Value = "To be Defined"
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks it is working , is it possible that In column J if it is 'renew' then in column AK cell should be blank then only it should insert "To be defined"
 
Upvote 0
Try this:
Code:
Sub Renew_Yes()
Application.ScreenUpdating = False
Dim c As Range
    For Each c In Range("J1:J" & Cells(Rows.Count, "J").End(xlUp).Row)
        If c.Value = "Renew" Then If c.Offset(, 27).Value = "" Then c.Offset(, 27).Value = "To be Defined"
    Next
Application.ScreenUpdating = True
End Sub
 
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