Insert Contents


S

Sal

Sub Insertcontents()

Range("I2:I" & Range("K" & Rows.Count).End(xlUp).Row).Formula = "04"

End Sub


I am using this macro to fill in blank cells in Column I with 04, depending
on whether Column K has contents in it. The problem I am having is that cells
in Column I which already have contents are being changed to 04 when I only
want the blank cells in Column I to be changed to 04.

I would like to adjust this macro so that if the cells in Column I are blank
they will be changed to 04, however if they already have contents in them
those contents will not be changed to 04. My target is to get both actions
to depend on whether Column K has contents in it. If Column K has contents
activate, if it does not, do not activate. Any help I appreciate.
 
Ad

Advertisements

D

Don Guillett

Sub Insertcontents()
For i = 2 To Cells(Rows.Count, "k").End(xlUp).Row
If Len(Application.Trim(Cells(i, "i"))) < 1 Then Cells(i, "i") = 4
Next i
End Sub
 
S

Sal

Perfect! Thank you.

Don Guillett said:
Sub Insertcontents()
For i = 2 To Cells(Rows.Count, "k").End(xlUp).Row
If Len(Application.Trim(Cells(i, "i"))) < 1 Then Cells(i, "i") = 4
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top