• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need offset property for Range selection

ThrottleWorks

Excel Ninja
Hi


I need help for selecting particular range by VBA.


I have a macro which select last cell in a particular column.

I want to select a range from that particular cell.

How can do it using Offset in VBA.


Following example will be easier to understand.


My last cell is “B18”, this is identified by the macro.

Now I want to select Range (“B18:AH18”) with the help of macro.


The cell reference B18 is not fixed, this can be B25, B50 etc.

I want my macro to select a range from that particular cell.

If the last cell is B50, then the macro should select Range (“B50:AH50”).


Please help…
 
Hi Sachin ,


If you are sure the end column will always be AH , then add the following lines of code to your existing macro :

[pre]
Code:
Set endcell = lastcell.Offset(0, 33) ' AH is 33 columns offset from column A
Range(lastcell, endcell).Select
[/pre]

Narayan
 
Back
Top