Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Error in code

The purpose of this code is to scan the entire sheet and move all data
greater than 7 characters to Col H to column I. I get an error in the If
Len statement. Any ideas?

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(Cells.Value) 7 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Error in code

You might want to try VBA.Len instead of just Len.

"JOUIOUI" wrote:

The purpose of this code is to scan the entire sheet and move all data
greater than 7 characters to Col H to column I. I get an error in the If
Len statement. Any ideas?

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(Cells.Value) 7 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Error in code

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each Cell In rng
If Len(Cell.Value) 7 Then
Cell.Offset(0, 1).Value = Cell.Value
Cell.ClearContents
End If
Next

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JOUIOUI" wrote in message
...
The purpose of this code is to scan the entire sheet and move all data
greater than 7 characters to Col H to column I. I get an error in the If
Len statement. Any ideas?

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(Cells.Value) 7 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Error in code

Typo

If Len(Cells.Value) 7 Then

remove the s
Cell.Value

--
Regards Ron De Bruin
http://www.rondebruin.nl



"JOUIOUI" wrote in message ...
The purpose of this code is to scan the entire sheet and move all data
greater than 7 characters to Col H to column I. I get an error in the If
Len statement. Any ideas?

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(Cells.Value) 7 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error in code

did you check against the original:

Sub MoveValues()
Dim rng as Range, cell as Range
set rng = Range(cells(2,"H"),cells(rows.count,"H").end(xlup) )
for each cell in rng
if len(cell) = 13 then
cell.offset(0,1).value = cell.value
cell.clearcontents
end if
next
End sub


--
Regards,
Tom Ogilvy

"JOUIOUI" wrote in message
...
The purpose of this code is to scan the entire sheet and move all data
greater than 7 characters to Col H to column I. I get an error in the If
Len statement. Any ideas?

' If text great than 7 characters in column H move text to to I Column

Set rng = Range(Cells(2, "H"), Cells(Rows.Count, "H").End(xlUp))
For Each cell In rng
If Len(Cells.Value) 7 Then
cell.Offset(0, 1).Value = cell.Value
cell.ClearContents
End If
Next



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
error code help vbidiot[_4_] Excel Programming 2 February 22nd 06 05:08 PM
Error in Code Jim May Excel Programming 6 May 9th 05 01:37 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 09:45 PM.

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"