What about trimming the variable before the comparison? The code above wouldn't catch an "empty" variable with spaces.
Side note:
Copying from excel I have found to be a pain. My solution was to either use <F2> to open the cell then have the macro select the contents or I have a macro that will select the entire spread sheet and convert it to a tabbed delimited csv file on my desktop. When reads much better into macro express.
It only takes about 40 lines of code to do this and produces much better results when working with excel. I left my headings in, you will notice I spent too much time creating the flowerbox
<REM2:++==========================================================++><REM2:*-^*-^*-^*-^*-^*-^*-^*-^*-^*-Macro Title-^*-^*-^*-^*-^*-^*-^*-^*-^*-^*-^*-^><REM2: Macro Title Create CSV From Excel><REM2: ><REM2: ><REM2:*-^*-^*-^*-^*-^*-^*-^*-^*-^*-Description-^*-^*-^*-^*-^*-^*-^*-^*-^*-^*-^*-^><REM2: Macro Description ><REM2: 1. Get claim information from spreadsheet><REM2: 2. Format to Comma Delimited><REM2: 3. Ouput to CSV File><REM2: ><REM2:~`~`~`~`~`~`~`~`~`~`~`~`Author`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`><REM2:.-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨).-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨)><REM2:(¸.-´ (¸.-´ (¸.-` (¸.-´(¸.-´ (¸.- First Name (¸.-´ (¸.-´-´(¸.- (¸.-´(¸.-´ -´(¸.- (¸.-´(¸.-´-´(¸.-><REM2:.-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨).-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨)><REM2: (¸.-´ (¸.-´-´(¸.- (¸.-´Last Name (¸.-´-´(¸.-´ (¸.-´-´(¸.-(¸.-´ -´(¸.- (¸.-´(¸.-´-´(¸.-(¸.-´(¸.-´><REM2:.-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨).-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨)><REM2: (¸.-´(¸.-(¸.-´-´(¸.- (¸.-´ (¸.-´-´04/29/09 -´ (¸.-´(¸.- (¸.-´ -´(¸.-(¸.-´(¸.-´ -´(¸.-(¸.-´(¸.-><REM2:.-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨).-*´¨) ¸.-*¨) ¸.-´¸.-*´¨) ¸.-*¨) ¸.-¸.-*´¨)¸.-*¨)><REM2:~`~`~`~`~`~`~`~`~`~`~`~`Mods`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`><REM2: MOD: User Name, Date, Description of Mod><REM2: ><REM2: ><REM2:++==========================================================++><REM2:><REM2:><REM2:><REM2:><REM2:-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-><REM2: Variables><REM2:-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-><REM2:T70: File Location><REM2:T70: Ouput Folder><REM2:T72: Data location><REM2:-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-><REM2: Variables><REM2:-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:************************************************************************
***************><REM2: Initalization><REM2:************************************************************************
***************><REM2:><REM2:+=--=+=--=+=--=+=File Path Setups+=--=+=--=+=--=+=><REM2:T70: File Location><VSETMISC:T70:Path to Desktop><REM2:T70: Ouput Folder><TMVAR2:07:70:00:000:000:\Excel To CSV Output><REM2:T72: Data location><TVAR2:72:01:%T70%\Excel SpreadSheet CSV.csv><REM2:><REM2:><REM2:+=--=+=--=+=--=+=Create CSV File+=--=+=--=+=--=+=><GETCONTROL:01:EXCEL.EXE:001:bosa_sdm_XL9Go To><TEXTTYPE:<F5>><WAITCONTROL:000010:000000:01:02><TEXTTYPE:A1<ENTER>><WAITPB><TEXTTYPE:<CTRL>a><WAITPB><REM2:><CLIPC><REM2:cannot empty clipboard!!!! excel crashes long wait needed><MSD:500><REM2:><REM2:><TVAR2:01:03:><REM2:><REM2:><REP3:08:000001:000001:0003:0:01:A><REM2:><TBOX4:T:3:Center000Top001158000332:000:Copied Contents%T1%><MENU2:2:T:03:000553Center:Verify SelectionIs the Above Screen The Proper Selected Excel Document? (Formatting too)
Note: The columns may not line up. Just verify that the information is there from the spread sheet.1: Yes
2: No><TBCLOSE:Copied Contents><REM2:><IFVAR2:1:03:1:B><REM2:><TBOX4:T:4:Center000Top000278000200:000:Correct SelectionSelected the cells that are to be looked up.
Press OK when done><REM2:><CLIPC><MSD:500><REM2:><TVAR2:01:03:><ENDIF><ENDREP><REM2:><REM2:><REM2:+=--=+=--=+=--=+=Output Excel to Readable Spread Sheet+=--=+=--=+=--=+=><TBOX4:T:3:CenterCenter000278000200:000:Please WaitFormatting Copied Information...
Processing><REM2:This allows for Comma Delimited, Standard is tab delimited><DIS:<TMVAR2:21:01:01:000:000: ,><REM2:><TMVAR2:17:01:00:000:000:%T72%F><TBCLOSE:Please Wait><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:><REM2:*************************************-END-*******************************************><REM2: Initalization><REM2:*************************************-END-*******************************************>
Cheers,
Don