ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Contents (https://www.excelbanter.com/excel-programming/428839-insert-contents.html)

Sal

Insert Contents
 
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.


Don Guillett

Insert Contents
 
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

"Sal" wrote in message
...
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.



Sal

Insert Contents
 
Perfect! Thank you.

"Don Guillett" wrote:

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

"Sal" wrote in message
...
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.




Don Guillett

Insert Contents
 
Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Sal" wrote in message
...
Perfect! Thank you.

"Don Guillett" wrote:

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

"Sal" wrote in message
...
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.






All times are GMT +1. The time now is 09:16 PM.

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