View previous topic :: View next topic |
Author |
Message |
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Jan 20, 2005 11:35 am Post subject: 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 |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Sun Jan 23, 2005 2:01 pm Post subject: |
|
|
Thanks to Bernard Liengme for the solution. If anyone else has a need, here it is:
Code: | Dim Sel As Object
Dim LastUsedRow As Long
Set Sel = Selection
LastUsedRow = Sel.Find("*", Sel.Cells(1, 1), , , xlByRows, xlPrevious).row |
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" _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|