SOLVED

Fill cells in a column with a repeating term then stop filling when other data ends

%3CLINGO-SUB%20id%3D%22lingo-sub-2399284%22%20slang%3D%22en-US%22%3EFill%20cells%20in%20a%20column%20with%20a%20repeating%20term%20then%20stop%20filling%20when%20other%20data%20ends%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2399284%22%20slang%3D%22en-US%22%3E%3CP%3EWIN%2010%2C%20Excel%202016.%26nbsp%3B%20I%20volunteer%20IT%20at%20a%20homeless%20center.%26nbsp%3B%20We%20use%20a%20sign%20in%20sheet%20drawn%20from%20Salesforce%2C%20downloaded%20into%20Excel%20then%20massaged%20by%20a%20macro%20to%20produce%20the%20printed%20list.%26nbsp%3B%20They%20want%20one%20column%20to%20have%20the%20term%20%22shelter%20out%22%20in%20every%20cell%20one%20column%20to%20mark%20where%20the%20client%20stayed%20the%20night%20before.%3C%2FP%3E%3CP%3EI%20can%20get%20the%20column%20to%20fill%20each%20cell%20correctly%20but%20I%20need%20it%20to%20stop%20filling%20when%20there%20is%20no%20more%20data%20in%20the%20other%20columns.%26nbsp%3B%20So%2C%20one%20day%20the%20list%20will%20have%20651%20clients%2C%20the%20next%20day%20it%20might%20have%20670.%3C%2FP%3E%3CP%3EBelow%20is%20the%20fill%20function%20from%20the%20macro.%26nbsp%3B%20How%20do%20I%20get%20it%20to%20stop%20when%20there%20is%20no%20data%20in%20adjoining%20cells%3F%3C%2FP%3E%3CP%3ESub%20Macro1()%3CBR%20%2F%3E'%3CBR%20%2F%3E'%20Macro1%20Macro%3C%2FP%3E%3CP%3E'%3CBR%20%2F%3ERange(%22J1%22).Select%3CBR%20%2F%3EActiveCell.FormulaR1C1%20%3D%20%22out%20shelt%22%3CBR%20%2F%3EColumns(%22J%3AJ%22).Select%3CBR%20%2F%3ESelection.FillDown%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2399284%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2420278%22%20slang%3D%22en-US%22%3ERe%3A%20Fill%20cells%20in%20a%20column%20with%20a%20repeating%20term%20then%20stop%20filling%20when%20other%20data%20ends%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2420278%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%20%26nbsp%3BThank%20you%20so%20much!%26nbsp%3B%20Works%20like%20a%20charm.%3C%2FP%3E%3CP%3EThis%20will%20make%20the%20volunteers%20job%20easier.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

WIN 10, Excel 2016.  I volunteer IT at a homeless center.  We use a sign in sheet drawn from Salesforce, downloaded into Excel then massaged by a macro to produce the printed list.  They want one column to have the term "shelter out" in every cell one column to mark where the client stayed the night before.

I can get the column to fill each cell correctly but I need it to stop filling when there is no more data in the other columns.  So, one day the list will have 651 clients, the next day it might have 670.

Below is the fill function from the macro.  How do I get it to stop when there is no data in adjoining cells?

Sub Macro1()
'
' Macro1 Macro

'
Range("J1").Select
ActiveCell.FormulaR1C1 = "out shelt"
Columns("J:J").Select
Selection.FillDown
End Sub

2 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@Ed Weyler 

Like this:

 

 

Sub Macro1()
    Dim m As Long
    m = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Range("J1:J" & m).Value = "out shelt"
End Sub

(Also posted on Microsoft Community)

 

@Hans Vogelaar   Thank you so much!  Works like a charm.

This will make the volunteers job easier.