View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_48_] Leith Ross[_48_] is offline
external usenet poster
 
Posts: 1
Default Looping with Excel Forms


Hello Jeff,

If the sheet name contains any trailing spaces, the converted valu
will be wrong. I had this happen not long ago while writing a macro fo
a client. The client sent me a copy of the workbook in which he wa
having trouble referencing the sheets. I tried to get the code to ru
and it failed. 3 days later I discoverd the client had aligned th
sheet names with trailing spaces. This allowed the sheet name to b
centered in the sheet tab at the bottom, but never compared correctly
I used a TRIM statement to get rid of any leading or trailing space
and the comparasions worked.

TO REMOVE ANY LEADING AND TRAILING SPACES FROM THE SHEET NAME
shName = Val(Trim(Right(CurSheet.Name, 3)))

If you have your macro in *Personal.xls* then you should change al
references of ThisWorkbook to ActiveWorkbook. ThisWorkbook refers t
the Workbook where the code is located, and ActiveWorkbook refers t
the Workbook with the Focus. It is a subtle but important distinction

--
Leith Ros

-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=38029