what year of car is it mate? You can recode your own original key to operate the doors, but cant code a new key to the immobiliser unless its already for the car, without a code from audi if its a newer model (immo 3 or 4), and they wont give you it now. Dealer only.
To reattach your remote to the central locking, most late 90's onward A4's just need the key in the ignition (type 3 or 4 immob) it reads the transponder chip in the key and knows its the correct key for the car. It then sends a signal via the CAN network to allow the learning function to sync the radio fob on the key) just push lock and unlock on the remote, turn ignition off, close door and press lock unlock again.