ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   evaluting cell contents for "type" and add row if the cell is bla (https://www.excelbanter.com/excel-discussion-misc-queries/169091-evaluting-cell-contents-type-add-row-if-cell-bla.html)

april

evaluting cell contents for "type" and add row if the cell is bla
 
i want to add rows if the contents of a cell in the row is blank. i am using
this macro. i want the macro to go down column c to look for blank cells -
if it encounters a blank cell, i want to insert a row. getting an error
message with the "if statement"

thanks in advance for the help



-- range("c9").Select
Count = 0
Do Until Count = 200
ActiveCell.Offset(1, 0).Select
If ActiveCell.FormulaR1C1 = "=CELL(""type"" = "b")" Then
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Count = Count + 1
Loop


End Sub
aprilshowers

Carim

evaluting cell contents for "type" and add row if the cell is bla
 
Hi April,

What about :

If IsEmpty(ActiveCell.Value) Then

HTH
Carim

Don Guillett

evaluting cell contents for "type" and add row if the cell is bla
 
Assumes length of occupied cells greater than 1 character.
Sub insertrowifblank()
For i = Cells(Rows.Count, "c").End(xlUp).Row To 2 Step -1
If Len(Cells(i, "c")) < 2 And Len(Cells(i - 1, "c")) 1 Then Rows(i).Insert
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"april" wrote in message
...
i want to add rows if the contents of a cell in the row is blank. i am
using
this macro. i want the macro to go down column c to look for blank
cells -
if it encounters a blank cell, i want to insert a row. getting an error
message with the "if statement"

thanks in advance for the help



-- range("c9").Select
Count = 0
Do Until Count = 200
ActiveCell.Offset(1, 0).Select
If ActiveCell.FormulaR1C1 = "=CELL(""type"" = "b")" Then
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Count = Count + 1
Loop


End Sub
aprilshowers




All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com