Scannerman
11-18-2004, 05:21 AM
Hi. I guess there's a pretty simple answer to this but I can't see it.
I want to use a counter in my Macro that ends when the counter reaches the value of a given cell. Obviously the conter is an integer so the value of the cell must be an integer but when I debug I get a "type mismatch" error. I'm guessing that the cell value is returned as a string rather than an integer.
Ok so here's the problem. How do I convert my cell value string to an integer to use in my counter?
I've tried "Value(Range("E1").Value)" but I get a "Sub or Function not defined" error, so the Value function is not availble. Any other ideas would be gratefully received.
PS In the attached if I change Hundreds, Fiftys & Twentys to numeric constants it runs fine (i.e Humdreds = 7; Fiftys = 4; Twentys = 5) but I wnt to be able to change the values from the spreadsheet.
I want to use a counter in my Macro that ends when the counter reaches the value of a given cell. Obviously the conter is an integer so the value of the cell must be an integer but when I debug I get a "type mismatch" error. I'm guessing that the cell value is returned as a string rather than an integer.
Ok so here's the problem. How do I convert my cell value string to an integer to use in my counter?
I've tried "Value(Range("E1").Value)" but I get a "Sub or Function not defined" error, so the Value function is not availble. Any other ideas would be gratefully received.
PS In the attached if I change Hundreds, Fiftys & Twentys to numeric constants it runs fine (i.e Humdreds = 7; Fiftys = 4; Twentys = 5) but I wnt to be able to change the values from the spreadsheet.