Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA - Insert row, copy contents of original row except for contents of columns A-N | Excel Programming | |||
VBA - Insert row, copy contents of original row except for contents of column A | Excel Programming | |||
Paste or insert data before and after cel contents | Excel Discussion (Misc queries) | |||
Insert row with formulae without contents | Excel Programming | |||
How can I insert the contents of a cell as a filename? | Excel Programming |