If you can't come to visit for objective reasons, apologize to each other and explain why the meeting did not take place. Tell them you're very sorry and hope to meet up later. Your friend will be pleased if you will invite him to visit, when both of you it will be convenient.
You may assume that the visit will not be too interesting, and you are wasting your time. If you feel uncomfortable to honestly explain the reason, refer to employment - not necessarily to go into details. If a friend would insist, you can refer to some mysterious circumstances, "There are problems... I'll tell you later – can't right now". You will have time to do, if a friend will further demonstrate curiosity.
If you are invited to a family celebration, be sure to call in this day and congratulate friends with a joyful event. Reaffirm how sorry I am that can't attend in person. If the reason for the invitation was the usual friendly party, call the next day and ask how it went.
Once you have accepted the invitation to go to visit would be very rude. A valid reason for a sudden failure can be disease, natural disaster or the unexpected arrival of relatives. Be sure to warn the owners that can't be, and politely apologize.
You may have received a better offer after accepting the invitation. If you want to abandon the visit, which has already been agreed, think about what you let down your friends. They plan the budget and maybe the script of the holiday and look forward to your presence. Besides, your refusal for such a reason, most likely, they are highly offended.
If you try to refuse the visit under the pretext that the truth can emerge at any time, especially if the new company will be the same people. In this case, you risk seriously to spoil relations with friends.