ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to select last active row (https://www.excelbanter.com/excel-programming/347403-how-select-last-active-row.html)

jcc31[_5_]

How to select last active row
 

Here is my code. I would like to know since every file has a different
amount of records, if there is a way process my code only to the last
active record?
In this case here I put 6500 records but I really do have that many
records.
And my record must start with the second record for processing.


Range("V2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(C[-2],"" "",C[-10],""
"",C[-16])"
Selection.AutoFill Destination:=Range("V2:V*6500*"),
Type:=xlFillDefault
Range("V2:V65000").Select
Selection.Copy
Range("F2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("T:Z").Select
Selection.ClearContents


--
jcc31
------------------------------------------------------------------------
jcc31's Profile: http://www.excelforum.com/member.php...o&userid=24692
View this thread: http://www.excelforum.com/showthread...hreadid=490965


AH·C[_10_]

How to select last active row
 

Try this:

Dim cell As Range
Dim lastCell As Range
Dim theCells As Range

Set lastCell = Cells(6500, ActiveCell.Column).End(xlUp) 'find the last
active cell, change 6500 up or down to ensure coverage

Set theCells = Range(Cells(*X*, *ActiveCell.Column*), lastCell) 'X is
the value of starting row, ie *2* and ActiveCell.Column can be a
defined value, i.e *"V"*

For Each cell In theCells
If Not IsEmpty(cell) Then
'your code to do whatever
End If
Next

HTH


--
AH·C
------------------------------------------------------------------------
AH·C's Profile: http://www.excelforum.com/member.php...o&userid=29108
View this thread: http://www.excelforum.com/showthread...hreadid=490965



All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com