Loop Starting from blank cells

NYQuicksale
NYQuicksale used Ask the Experts™
on
I want the below loop to get started from the whatever first cell is populated within the symbols sheet. e.g if cell A1,A2,A3 are blank then automatically start from A4.

Sub loopA()
Dim cel As Range
Dim sh As Worksheet

Set sh = Sheets("info")

For Each cel In Sheets("symbols").Range("A1:A" & Sheets("symbols").Range("A1").End(xlDown).Row)
sh.Range("A1") = cel.Value
Next cel
End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
What is your code doing - it is just overwriting A1 each time? You don't need a loop at all do you?
Try

For Each cel In Sheets("symbols").Range("A" & Sheets("symbols").Range("A1").End(xlDown).Row & ":A" & Sheets("symbols").Range("A1").End(xlDown).End(xlDown).Row)

Author

Commented:
i need a loop, this is the same, that u just amended, earlier it was taking in blank cells as well, while now i want it to start from whatever populated cell is in the Column A, i mean not to start from some fixed cell i-e A1 or A2, i want it to check from which cell it is starting the non-blank cells, and then get into the loop from that cell onwards
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

But since you are putting everything into A1 what is the point? Only the last value will remain.
Try this... nonBlankRow will have the row number of the first non-blank row.
sew

Sub LoopA()
    Dim cel As Range
    Dim sh As Worksheet
    
    Set sh = Sheets("info")
    
    Set sh2 = Sheets("symbols")
    sh2.Range("A1").Select
    Selection.End(xlDown).Select
    
    Dim nonBlankRow As Integer
    nonBlankRow = ActiveCell.Row

    For Each cel In Sheets("symbols").Range("A" & nonBlankRow & ":A" & Sheets("symbols").Range("A" & nonBlankRow).End(xlDown).Row)
        sh.Range("A1") = cel.Value
    Next cel
End Sub

Open in new window

Presumably you don't care to explain what you're doing then!

Author

Commented:
stephen sorry, i dont have time actually to explain everything what i do, and in that hurry, i accepted solution which is not working for one symbol, so i'm posting a new question, that would be for u, i'm gonna explain everything there.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_27238987.html

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial