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 error

I'm using the following code to Clean and Trim data in Col B.
Most cells in the range contain data. Most data is text.
Cell ("B1") appears to be empty.

Immediately I run the following code, I receive an "Invalid use
of Null" error in "B1" :

Sub InitialFormat()

Dim C As Range, FormatRng As Range

Set FormatRng = ActiveSheet.UsedRange.Columns(2)
For Each C In FormatRng
With C
.RowHeight = 12.75
If Not IsEmpty(C) Then
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
End If
.Rows.AutoFit
End With
Next
End Sub

Why is this please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004


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

Hi Stuart,

Try changing:

Set FormatRng = ActiveSheet.UsedRange.Columns(2)


to:

Set FormatRng = ActiveSheet.UsedRange.Columns(2).Cells

As your code stands, C refers to a column rather than cell and C.Value
references an array of values.

---
Regards,
Norman



"Stuart" wrote in message
...
I'm using the following code to Clean and Trim data in Col B.
Most cells in the range contain data. Most data is text.
Cell ("B1") appears to be empty.

Immediately I run the following code, I receive an "Invalid use
of Null" error in "B1" :

Sub InitialFormat()

Dim C As Range, FormatRng As Range

Set FormatRng = ActiveSheet.UsedRange.Columns(2)
For Each C In FormatRng
With C
.RowHeight = 12.75
If Not IsEmpty(C) Then
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
End If
.Rows.AutoFit
End With
Next
End Sub

Why is this please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004




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

Regards and thanks.

"Norman Jones" wrote in message
...
Hi Stuart,

Try changing:

Set FormatRng = ActiveSheet.UsedRange.Columns(2)


to:

Set FormatRng = ActiveSheet.UsedRange.Columns(2).Cells

As your code stands, C refers to a column rather than cell and C.Value
references an array of values.

---
Regards,
Norman



"Stuart" wrote in message
...
I'm using the following code to Clean and Trim data in Col B.
Most cells in the range contain data. Most data is text.
Cell ("B1") appears to be empty.

Immediately I run the following code, I receive an "Invalid use
of Null" error in "B1" :

Sub InitialFormat()

Dim C As Range, FormatRng As Range

Set FormatRng = ActiveSheet.UsedRange.Columns(2)
For Each C In FormatRng
With C
.RowHeight = 12.75
If Not IsEmpty(C) Then
.Value = (WorksheetFunction.Clean _
(WorksheetFunction.Trim(.Text)))
End If
.Rows.AutoFit
End With
Next
End Sub

Why is this please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.778 / Virus Database: 525 - Release Date: 15/10/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
Invalid Use of Null AL Excel Programming 3 August 24th 04 09:56 AM
Invalid Property Value Error LarryP[_2_] Excel Programming 6 August 3rd 04 07:33 PM
Invalid picture Error?!? Tom Excel Programming 1 May 4th 04 10:36 AM
Invalid Data error Ajit[_4_] Excel Programming 0 March 5th 04 03:21 PM
Invalid use of Null Stuart[_5_] Excel Programming 2 February 21st 04 08:22 AM


All times are GMT +1. The time now is 11:41 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"