Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
hello
another (I am sure) banal problem I am not able to cope with. I need to name a variable named after 3 first characters of active cell. I tried dim var var = left(activecell.value, 3) i tried also dim var, var1 var = activecell.value var1 = left(var, 3) as suggested in one of the threads but I always get an error on this line of code active cell contains text any help appreciated thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
Sorry,
I have tried the following code Sub test() Dim var, var1 var = ActiveCell.Value var1 = Left(var, 3) Debug.Print var1 End Sub and it worked fine on my machine (Excel 2000). There should not be a problem with your code but I guess that doesn't help you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
I have created this:
Public Sub threeChars() Dim strValue As String ' strValue = ActiveCell.Text strValue = strValue & "___" ' 3 extra characters so next statement will not gif an error strValue = Left(strValue, 3) MsgBox strValue End Sub Check your regional settings you might need: Public Sub threeChars() Dim strValue As String ' strValue = ActiveCell.Text strValue = strValue & "___" ' 3 extra characters so next statement will not gif an error strValue = Left(strValue; 3) MsgBox strValue End Sub Hoop This Helps Executor |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
Hi Shark,
your variable assignments work for me. What error are you getting? What is the code which produces the error? --- Regards, Norman "shark102" wrote in message ... hello another (I am sure) banal problem I am not able to cope with. I need to name a variable named after 3 first characters of active cell. I tried dim var var = left(activecell.value, 3) i tried also dim var, var1 var = activecell.value var1 = left(var, 3) as suggested in one of the threads but I always get an error on this line of code active cell contains text any help appreciated thanks in advance |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
I always get word keft highlighted (and it does not start with capital letter
as it should) and message error is - compile error: wrong number of argumewnts or invalid property assignment I am confused "Norman Jones" wrote: Hi Shark, your variable assignments work for me. What error are you getting? What is the code which produces the error? --- Regards, Norman "shark102" wrote in message ... hello another (I am sure) banal problem I am not able to cope with. I need to name a variable named after 3 first characters of active cell. I tried dim var var = left(activecell.value, 3) i tried also dim var, var1 var = activecell.value var1 = left(var, 3) as suggested in one of the threads but I always get an error on this line of code active cell contains text any help appreciated thanks in advance |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
In the VBE, go to Tools=References and see if you have a reference marked
as MISSING. If you find one, you need to eliminate it as a reference or fix it. In the meantime, instead of Left, use VBA.Left -- Regards, Tom Ogilvy "shark102" wrote in message ... hello another (I am sure) banal problem I am not able to cope with. I need to name a variable named after 3 first characters of active cell. I tried dim var var = left(activecell.value, 3) i tried also dim var, var1 var = activecell.value var1 = left(var, 3) as suggested in one of the threads but I always get an error on this line of code active cell contains text any help appreciated thanks in advance |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
name variable with 3 first characters of active cell
That sounds like you have greated a variable, function or sub named LEFT.
You need to give this a new name. It may not be that easy to fix. You can try exiting Excel and reopening. If that doesn't help, export all your code modules and delete them in the workbook, then save the workbook. Then import the code again. -- Regards, Tom Ogilvy "shark102" wrote in message ... I always get word keft highlighted (and it does not start with capital letter as it should) and message error is - compile error: wrong number of argumewnts or invalid property assignment I am confused "Norman Jones" wrote: Hi Shark, your variable assignments work for me. What error are you getting? What is the code which produces the error? --- Regards, Norman "shark102" wrote in message ... hello another (I am sure) banal problem I am not able to cope with. I need to name a variable named after 3 first characters of active cell. I tried dim var var = left(activecell.value, 3) i tried also dim var, var1 var = activecell.value var1 = left(var, 3) as suggested in one of the threads but I always get an error on this line of code active cell contains text any help appreciated thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set a variable to the active cell | Excel Discussion (Misc queries) | |||
searching for the first few characters in an active cell | Excel Programming | |||
Excel VBA-use variable in active cell formula problem | Excel Programming | |||
value of active cell into a variable | Excel Programming | |||
Delete Characters in an active cell | Excel Programming |