View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Driscol[_2_] Mark Driscol[_2_] is offline
external usenet poster
 
Posts: 75
Default Help stopping when row is blank

PJ, the code

Range("H65536").End(xlUp).Offset(-1, -2).Select

will select the cell one row above and two columns to the left of the
last cell in Column H with an "x" in it.

Can you be more specific about what cells you want to do? Say there
are data in cells F1:F25 and "x"s in cells H1:H10. What specific cells
do you want selected and what cells do you want autofilled?


Mark


PJ wrote:
I am new to VBA. I recorded a macro and applied it to the command
button to fill two seperate ranges down. Now I want to edit the code to
do the following:
After I run (click the command button), the cursor stops at the cell
"F1169". I fill in the cells in column "H" with an "x" to indicate I
have finished analyizing that row. I would like the cursor to change
locations based on if the cell in column H is blank by going to the
last cell in column H with an "x" and then offset (-1,-2).
Also, when I recorded the macro, I set the range (to fill down) to
1500. I add new rows to include more data daily. The 1500# was overkill
and I only used it because I will never have that much data. I would
like to clean up the range down to stop if there is nothing in the last
row of column "C". I hope some of this makes sense. I have been
researching to find an answer on my own with no luck. Please help.

Private Sub CommandButton1_Click()
Range("F4").Select
Selection.AutoFill Destination:=Range("F4:F1500"),
Type:=xlFillDefault
Range("F4:F1500").Select
ActiveWindow.LargeScroll Down:=-42
ActiveWindow.SmallScroll Down:=-21
Range("O4:P4").Select
Selection.AutoFill Destination:=Range("O4:P1500"),
Type:=xlFillDefault
Range("O4:P1500").Select
ActiveWindow.LargeScroll Down:=-19
ActiveWindow.SmallScroll Down:=249
Range("F1169").Select
End Sub