Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 82
Default Test for null - insert a row if isnull

Hi,

In a Macro (VBA) I am testing cell A6 for null, if isnull (""), I want to
insert a row. The problem is that it always inserts a row even when cell A6
has something in it? There are blank spaces at the from of the cell so I
trimmed it. Does anyone see something I'm doing wrong?


Sheets("Sheet1").Select
Range("A6").Select
If Trim(A6) = "" Then
Range("A4").Select
Selection.EntireRow.Insert
End If

Thanks in advance.

Bonnie
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Test for null - insert a row if isnull

Should be ....

Trim(Range("A6"))

"Bonnie" wrote:

Hi,

In a Macro (VBA) I am testing cell A6 for null, if isnull (""), I want to
insert a row. The problem is that it always inserts a row even when cell A6
has something in it? There are blank spaces at the from of the cell so I
trimmed it. Does anyone see something I'm doing wrong?


Sheets("Sheet1").Select
Range("A6").Select
If Trim(A6) = "" Then
Range("A4").Select
Selection.EntireRow.Insert
End If

Thanks in advance.

Bonnie

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Test for null - insert a row if isnull

Use it like this

This line is wrong
If Trim(A6) = "" Then



Sub Test()
Sheets("Sheet1").Select

If Trim(Range("A6")) = "" Then
Range("A4").EntireRow.Insert
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Bonnie" wrote in message ...
Hi,

In a Macro (VBA) I am testing cell A6 for null, if isnull (""), I want to
insert a row. The problem is that it always inserts a row even when cell A6
has something in it? There are blank spaces at the from of the cell so I
trimmed it. Does anyone see something I'm doing wrong?


Sheets("Sheet1").Select
Range("A6").Select
If Trim(A6) = "" Then
Range("A4").Select
Selection.EntireRow.Insert
End If

Thanks in advance.

Bonnie

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 82
Default Test for null - insert a row if isnull

Thank you both for responding. I'll give it a try.

"Ron de Bruin" wrote:

Use it like this

This line is wrong
If Trim(A6) = "" Then



Sub Test()
Sheets("Sheet1").Select

If Trim(Range("A6")) = "" Then
Range("A4").EntireRow.Insert
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Bonnie" wrote in message ...
Hi,

In a Macro (VBA) I am testing cell A6 for null, if isnull (""), I want to
insert a row. The problem is that it always inserts a row even when cell A6
has something in it? There are blank spaces at the from of the cell so I
trimmed it. Does anyone see something I'm doing wrong?


Sheets("Sheet1").Select
Range("A6").Select
If Trim(A6) = "" Then
Range("A4").Select
Selection.EntireRow.Insert
End If

Thanks in advance.

Bonnie


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
COUNTIF says Null = Blank but Blank < Null Epinn Excel Worksheet Functions 4 October 25th 06 08:03 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
Search for a test string and if found insert 'x' in clumn 'A' TCL Excel Discussion (Misc queries) 2 September 21st 05 05:18 PM
Formulas (If linked data is not null, then insert "Complete" in ce Task Lead Nicole Excel Worksheet Functions 3 January 10th 05 06:25 PM
ISNULL function - can't find it KitKat Excel Worksheet Functions 6 December 3rd 04 04:55 AM


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