Fill down a column if adjacent cell is not blank

Peterfc2

Active Member
Joined
Jan 2, 2004
Messages
354
Hi
I want to fill down column A with (- minus sign in A1) until blank cell is found in column B.

Sure I've down this before but can I remember??? NO!
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,871
Office Version
  1. 2013
Platform
  1. Windows
Try This:
Code:
Sub Minus()
Dim i
Dim a
Lastrow = Range("B1").End(xlDown).Row
For i = 1 To Lastrow
If (Cells(i, 2)) = "" Then
Cells(i, 1) = "-"
End If
Next
End Sub
 

bbott

Well-known Member
Joined
Feb 5, 2010
Messages
2,350
Here's another option that may be faster if you have a lot of data:

Code:
Sub DashDown()

    Range("A1:A" & Range("B" & Rows.Count).End(xlUp).Row) = "-"
    
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,389
Messages
5,528,419
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top