Question for any VBA gurus
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Question for any VBA gurus
There's a small problem with the DPlot Add-In that I'd like to address but I have reached the limit of my VBA knowledge. Most of the Add-In functions are designed to allow blank rows in the selection, which are simply ignored. So you can have 1000 rows of data followed by one or more blank rows followed by another 1000 rows of data, for example. This leads to an inefficiency when you make a selection by clicking column headers rather than dragging the cursor or using key combinations like Ctrl+Shift+End: the Add-In will look at all 65,536 rows on the sheet to see if there's any data there. If not for the "allow blank rows" feature I could simply stop at the first blank row. This doesn't cause any problems but is of course much slower than it needs to be. Excel obviously knows where the data stops or Ctrl+Shift+End would not work. So... in VBA what's the magic command to return the last used row?
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Thanks to Bernard Liengme for the solution. If anyone else has a need, here it is:
Need a good Excel reference? Check out Bernard's work: http://www.stfx.ca/people/bliengme/, including "A Guide to Microsoft Excel for Scientists and Engineers" and "A Guide to Microsoft Excel for Business and Management"
Code: Select all
Dim Sel As Object
Dim LastUsedRow As Long
Set Sel = Selection
LastUsedRow = Sel.Find("*", Sel.Cells(1, 1), , , xlByRows, xlPrevious).row
Visualize Your Data
support@dplot.com
support@dplot.com