ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Selecting offset cells (https://www.excelbanter.com/excel-discussion-misc-queries/92029-selecting-offset-cells.html)

Zygan

Selecting offset cells
 

Just a quick enquiry if some one will
thanks.

i have a macro that checks the cell value and if the cell value = my
value then i want it to delete the whole row
However i just need a code that can either derive the row number from
and active cell or select and delete a row depending on the active
cell
thanks


--
Zygan
------------------------------------------------------------------------
Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423
View this thread: http://www.excelforum.com/showthread...hreadid=548234


kassie

Selecting offset cells
 
Do you want to delete the row in which the active cell is, or an offset row?

"Zygan" wrote:


Just a quick enquiry if some one will
thanks.

i have a macro that checks the cell value and if the cell value = my
value then i want it to delete the whole row
However i just need a code that can either derive the row number from
and active cell or select and delete a row depending on the active
cell
thanks


--
Zygan
------------------------------------------------------------------------
Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423
View this thread: http://www.excelforum.com/showthread...hreadid=548234



Bob Phillips

Selecting offset cells
 
You do't need to check the active cell or select anything, all you need to
do is loop through a range checking it. Also, when deleting, it is always
best to work bottom-up.

For example, this dchecks column A and deletes the row

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(,"A").Value = "myValue" Then
Rows(i).delete
End If
Next i

End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Zygan" wrote in
message ...

Just a quick enquiry if some one will
thanks.

i have a macro that checks the cell value and if the cell value = my
value then i want it to delete the whole row
However i just need a code that can either derive the row number from
and active cell or select and delete a row depending on the active
cell
thanks


--
Zygan
------------------------------------------------------------------------
Zygan's Profile:

http://www.excelforum.com/member.php...o&userid=34423
View this thread: http://www.excelforum.com/showthread...hreadid=548234





All times are GMT +1. The time now is 12:31 AM.

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