Friday, October 17, 2014

Macro Tricks (Part 1)

For this time i will give you some tricks macro in Excel :

1. How to select second until last of row :

Dim Lastrow As Integer
Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

Range("A2:L" & Lastrow).Select

Lastrow is variable to identify what is number of cell with data.
after that we will select which row we need to be selected. if we want to select manually, we can select row with

Range("A2:L100").Select
it will indicate we select cell A2 until L100, but in this case we want to dynamic selection depend on data in that sheet. so we will put Lastrow number which we identified before. and the script will be like above.

2. How to select next cell after last active cell

Range("A2").end(xldown).select
Activecell.offset(1,0).select
with this script we will get the next cell after last active cell in column A.

Thats all from me, hopefully this can help you guys.

Thank you.
FA

0 komentar:

Post a Comment

Powered by Blogger.