Write text "hello" in cell A2 if text is cell B2

Galego

New Member
Joined
May 8, 2017
Messages
43
Hello

I’d like to write a macro scrip which if there is any text in A2 Macro writes “hello” in B2. I would like this rule to go down to the last row in the sheet.

Thanks,
David
 
"Didn't work" is usually a meaningless phrase, rather what you observed that allowed you to come to that conclusion is what determines the remedy. :D

But just by glance I notice syntax errors like missing quotes... I am not sure if the forums is displaying what you pasted wrong but try putting any code inside code tags...


Code:
i = 1 + 1

hwWkBOG.png
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Sorry. This script works for me.

Code:
[/COLOR]

[COLOR=#333333]Sub dispute()[/COLOR]

[COLOR=#333333]    Range("M20").Value2 = "=IF(P20<>"""",""Hello123"","""")"[/COLOR]
[COLOR=#333333]    Range("M20").AutoFill Range(Range("M20"), Range("A20").End(xlDown).Offset(0, [/COLOR][COLOR=#333333]12[/COLOR][COLOR=#333333]))[/COLOR]

[COLOR=#333333]End Sub

Only thing is that when cell P is blank (has no text) then makes M go blank too. Column M has a formula (=IF(G15<=0, "Open", IF(G15>0, "Overdue"))). What I want to do is that if Macro finds text (in for instance) Cell P15 write text "hello..." in M15 but if finds no text in cell P15 it leaves the formula =IF(G15<=0, "Open", IF(G15>0, "Overdue"))

Does it now make sense what I am trying to do?

Thanks.



 
Last edited:
Upvote 0
No :D... does this table start on row 15 or row 20?

screenshot your table, im having a hard time picturing what you are saying

ill just tell you what your code is doing...

1. you input into M20...

Code:
=IF(P20<>"","Hello123","")

English: if p20 is not blank then write hello123 in M20

2. Then you figured out the last cell of column A based on searching for blanks by traveling down from row 2

3. Then from that cell you traveled right 12 cells and you land in column M on the same row you found in step 2

4. Then you dragged down the formula you wrote in step 1 to the cell you found in step 3

hope that helps
 
Last edited:
Upvote 0
Yes in Satus column which it is column D but only if Macro finds a text in column P "Comments". If column P is blank then I want to leave the formula which it is already there =IF(G15<=0, "Open", IF(G15>0, "Overdue"))
 
Last edited:
Upvote 0
Status column is the 12th one to the right, assuming no columns are hidden then that would be column L

Isnt column D the Invoice Date?
 
Upvote 0

Forum statistics

Threads
1,216,182
Messages
6,129,360
Members
449,506
Latest member
nomvula

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