Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2264
  • Last Modified:

VB Command to move cursor to first empty row of table

I am recording an Excel macro and need it to select the first empty field at the bottom of a particular column.  The number of rows in the column will vary every time I run the macro.  

I've figured out a way to have the macro move to the last row of data of the column with this command:

Selection.End(xlDown).Select

If column F has 8 rows of data, the above lands me on F8.  But I then need to move the cursor down one more row to F9.  When I use the macro recorder, Excel records a literal address of F9 like this:

Range("F9").Select

But the next time I run it column F might have 10 rows of data.  What command do I use to move down one?
0
witzph1
Asked:
witzph1
  • 2
1 Solution
 
FlysterCommented:
Try something like this:

I= Selection.End(xlDown).Select
Range("F"& I+1).Range

Flyster
0
 
NorieData ProcessorCommented:
Try this.
Range("F" & Rows.Count).End(xlUp).Offset(1).Select

Open in new window

0
 
witzph1Author Commented:
This gives does exactly what I need and does it in the most elegant fashion. Thank you!
0
 
FlysterCommented:
I agree. Nice code imnorie!
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now