Solved

Select third blank cell in row

Posted on 2013-11-13
309 Views
How do I tell this to select the third blank cell in row 4?  Then I increment the (1) it moves down another cell.

Rows("4").SpecialCells(xlBlanks).Cells(1).Activate
0
Question by:RWayneH
• 4
• 2

LVL 33

Expert Comment

ID: 39645381
Are the cells in row 4 filled with non-contiguous values?
0

Author Comment

ID: 39645622
yes..  2 nonblank, 2 blank, 3 non than another blank.  Also it will vary based on a download.  It could even by the first three of the row are blank... and it should pick C4.

Hope this helps. -R-
0

LVL 31

Expert Comment

ID: 39647659
You can include this into a Do Loop:

``````Count = 0
Rows("4").Select
Do
For each Cell in Selection
If cell.value = "" then count = count +1
Col = Cell.Column
Loop Until Count = 4
Cells(4, Col).Select
``````
Thanks
Rob H

Edit:  line 7 should be: Loop Until Count = 3
0

Author Comment

ID: 39647752
Compile Error on Ln7  "Loop without Do"  Please advise and thanks. -R-
0

Author Comment

ID: 39647816
Here is what I came up with... is there a way to condense this down?  Your code did not work. -R-

``````Sub TestFindThirdBlankCell()

Range("C4").Select
ActiveCell.FormulaR1C1 = " "

Rows("4").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(0, 1).Select   '(1, 0) = move down one.  0, 1 = move one right
Loop  'ends on the blank
ActiveCell.FormulaR1C1 = " "
'Do it again
Rows("4").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(0, 1).Select   '(1, 0) = move down one.  0, 1 = move one right
Loop  'ends on the blank
ActiveCell.FormulaR1C1 = "Total Price"
ActiveCell.Offset(0, 1).Select  'move one right
ActiveCell.FormulaR1C1 = "Cost Over Base"

End Sub
``````
0

LVL 31

Accepted Solution

Rob Henson earned 500 total points
ID: 39647968
I have now spotted the error but surprised it was reported in the way you mention.

Code should be:

``````Count = 0
Rows("4").Select
Do
For each Cell in Selection
If cell.value = "" then count = count +1
Col = Cell.Column
Next Cell
Loop Until Count = 4
Cells(4, Col).Select
``````

Note addition of "Next Cell" in Line 7
Apologies,
Rob H
0

Author Closing Comment

ID: 39649127
Thanks worked awesome.. EXCELent!  -R-
0

Featured Post

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.