Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set a variable to the active cell Richard Excel Discussion (Misc queries) 1 March 24th 08 05:42 PM
searching for the first few characters in an active cell Chris Excel Programming 1 June 17th 04 10:27 PM
Excel VBA-use variable in active cell formula problem waveracerr Excel Programming 9 February 6th 04 02:49 PM
value of active cell into a variable TusaJii Excel Programming 1 January 24th 04 05:54 PM
Delete Characters in an active cell Don[_9_] Excel Programming 1 September 12th 03 07:01 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"