In Excel, let's I have data in B2 to B7 and C2 to C7 . In VBA I can write a macro to select it:
Sub Macro1()
Range("B2:C7").Select
End Sub
How do I rewrite the code so that it chooses automatically the cells that are non-empty? If I delete the data in cell B7 and C7 then I want the macro to select only Range(B2:C6) And if I add data to Cell B8 and C8 then I want the macro to choose Range(B2:C8).
My data will always start a B2,C2 and I will not have any free space between data.
Range(B2:C7)
the cellsB4
andC4
will be cleared, so you will need to select theRange(B2:C3)
or you still need to selectRange(B2:C7)
? – Vasily Ivoyzha