NYQuicksale
asked on
Loop Starting from blank cells
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
What is your code doing - it is just overwriting A1 each time? You don't need a loop at all do you?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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
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
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
Presumably you don't care to explain what you're doing then!
ASKER
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.
https://www.experts-exchange.com/questions/27238987/Loop-Problem.html
https://www.experts-exchange.com/questions/27238987/Loop-Problem.html