Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Invalid use of Null

For Each C In .UsedRange
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

appears to work fine.

However, in amending the code so as to operate on
cols A:D only, using

For Each C In .UsedRange.Columns("A:D")
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

I get "Invalid use of Null" on the .Value line.

Why is this, and how do I resolve it please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Invalid use of Null

..Columns(1) returns a Column, not a Range. Try:

Dim C As Range
With ActiveSheet
For Each C In .UsedRange.Columns("A:D").Cells
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next C
End With


In article ,
"Stuart" wrote:

For Each C In .UsedRange
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

appears to work fine.

However, in amending the code so as to operate on
cols A:D only, using

For Each C In .UsedRange.Columns("A:D")
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

I get "Invalid use of Null" on the .Value line.

Why is this, and how do I resolve it please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Invalid use of Null

Yes, I can see that now.
Many thanks.

Regards.

"JE McGimpsey" wrote in message
...
.Columns(1) returns a Column, not a Range. Try:

Dim C As Range
With ActiveSheet
For Each C In .UsedRange.Columns("A:D").Cells
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next C
End With


In article ,
"Stuart" wrote:

For Each C In .UsedRange
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

appears to work fine.

However, in amending the code so as to operate on
cols A:D only, using

For Each C In .UsedRange.Columns("A:D")
With C
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
.WrapText = False
End With
Next

I get "Invalid use of Null" on the .Value line.

Why is this, and how do I resolve it please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004


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
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
product key invalid? Emiljan Excel Discussion (Misc queries) 2 January 21st 08 05:55 PM
invalid references Shooter Excel Worksheet Functions 2 January 14th 08 11:20 PM
COUNTIF says Null = Blank but Blank < Null Epinn Excel Worksheet Functions 4 October 25th 06 08:03 PM
cell value based on null/not null in another cell spence Excel Worksheet Functions 1 February 18th 06 11:49 PM


All times are GMT +1. The time now is 07:32 PM.

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

About Us

"It's about Microsoft Excel"