excel vba find first empty cell in column range - moving down column
Posted on 2012-09-02
I have a worksheet that I have set ranges. My issue is I can not seem to find the code to start at the first cell in range and go down to find the first instance of blank-empty cell in that range and set it as part of the range to copy.
All ranges are in Column A
(First Range to evaluate)
range1 = sheet1.Range("A2:A52")
I need to start at Range("A2") and go down column range and find the first empty cell and use that cell above that as the end of the range to copy .... then I would set my new range to copy.
If "A30" was "" or blank then "A29" would be the end of my new range.
Not to muddy the water too much, but I need to add that I identify my first cell to copy by using a find:
Set xFind_First = sheet1.Range("A2:A52").Find(What:="MAINLINE", lookat:=xlPart) then I want to use the xFind_First.offset(0,1) as the beginning of my new range to copy.
And my xFind_Last would be the first cell in that range that is blank with .offset(0,-1)
How would the range be called if the
xFind_First.offset(0,1) : xFind_Last.offset(0,-1) is my new range to copy??
Then I move onto my 2nd range to evaluate that is also in Column A that will have a blank cell as the end of the range. I was limited from using an xlup process.
I hope you can assist me!