Using LEN in a macro

E

Ellen G

I have an IF statement in my macro that uses LEN() to test if a cell has more
than 250 characters. If the cell has more than 250 characters, the IF steps
take place. Otherwise they don't and the macro continues.

However, the problem I'm encountering is that if the cell has less than 10
characters in it, my test doesn't work and the IF steps take place when they
shouldn't. Any thoughts? The IF statement is as follows:

MyCell = ActiveCell
If ActiveCell.Value <> "[Client Receives]" And Len(MyCell) > "250" Then
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If

Thanks for your help.
Ellen
 
B

Bob Phillips

len is numeric

MyCell = ActiveCell
If ActiveCell.Value <> "[Client Receives]" And Len(MyCell) > 250 Then
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
E

Ellen G

OF COURSE!!! Silly me. Thanks so much.

Ellen

Bob Phillips said:
len is numeric

MyCell = ActiveCell
If ActiveCell.Value <> "[Client Receives]" And Len(MyCell) > 250 Then
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



Ellen G said:
I have an IF statement in my macro that uses LEN() to test if a cell has
more
than 250 characters. If the cell has more than 250 characters, the IF
steps
take place. Otherwise they don't and the macro continues.

However, the problem I'm encountering is that if the cell has less than 10
characters in it, my test doesn't work and the IF steps take place when
they
shouldn't. Any thoughts? The IF statement is as follows:

MyCell = ActiveCell
If ActiveCell.Value <> "[Client Receives]" And Len(MyCell) > "250" Then
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If

Thanks for your help.
Ellen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Setting Range with a Loop 1
Macro to run on hidden sheet 4
Copy of VB code to new spreadsheet 6
Macro 3
Looping Macro 5
Help with Macro's 0
Macro to copy/paste from one workbook to another 8
Help with a macro 2

Top