Link to home
Start Free TrialLog in
Avatar of Jeffrey Vogelzang
Jeffrey Vogelzang

asked on

Automatically fill columns with formula with conditions

I have columns in an Excel sheet that I would like to automatically fill with a formula.

The VBA code I currently have is:
Range("M3") = "=J3&"" & ""&K3": Range("M3:M" & lRow).FillDown

However, column K contains the spouse's name if they have one, which means sometimes the cell in column K is blank.  If the person doesn't have a spouse, column M then reads:
First Name (from column J) &.

I've tried the following code but it causes an error:
Range("M3") = IF(Len(K3)=),"=J3&","=J3&"" & ""&K3": Range("M3:M" & lRow).FillDown

Any suggestions?
Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeffrey Vogelzang
Jeffrey Vogelzang

ASKER

Thank you for a quick and correct answer. Not sure why I didn't think of that, but...
You're welcome Jeffrey! Glad I could help.