Define the variable as Public (instead of Dim). eg Workbook B would need a line like :-

Code:
Public MyVariable As String