![]() |
Using LEN in a macro
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 |
Using LEN in a macro
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" wrote in message ... 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 |
Using LEN in a macro
OF COURSE!!! Silly me. Thanks so much.
Ellen "Bob Phillips" wrote: 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" wrote in message ... 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 |
All times are GMT +1. The time now is 10:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com