ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need to delete last value in column but not delete entire row (https://www.excelbanter.com/excel-programming/375493-need-delete-last-value-column-but-not-delete-entire-row.html)

[email protected]

Need to delete last value in column but not delete entire row
 
This little snippet works great if I need to delete the last row, but
how can I tweak it where I need to delete the last value in a column
only and not delete the entire row?

Sub test()
Rows(Range("A2:A5").End(xlDown).Row).Delete

End Sub


Example:
Col A Col B
1 Header Header
2 value a value a
3 value b value b
4 value c value c
5 value d value d

Based on this example I would want to remove "value d" from Col A only,
but keep "value d" in Col B and so on and so on if I had other values
in row 5 in other Columns after B.


bobbo

Need to delete last value in column but not delete entire row
 

wrote:
This little snippet works great if I need to delete the last row, but
how can I tweak it where I need to delete the last value in a column
only and not delete the entire row?

Sub test()
Rows(Range("A2:A5").End(xlDown).Row).Delete

End Sub


Example:
Col A Col B
1 Header Header
2 value a value a
3 value b value b
4 value c value c
5 value d value d

Based on this example I would want to remove "value d" from Col A only,
but keep "value d" in Col B and so on and so on if I had other values
in row 5 in other Columns after B.



Range("a2:a5").End(xlDown).Delete


[email protected]

Need to delete last value in column but not delete entire row
 
When using Range("a2:a5").End(xlDown).Delete, it does delete the value
from A5, but then it shifts the value B5 over to cell A5.


bobbo wrote:
wrote:
This little snippet works great if I need to delete the last row, but
how can I tweak it where I need to delete the last value in a column
only and not delete the entire row?

Sub test()
Rows(Range("A2:A5").End(xlDown).Row).Delete

End Sub


Example:
Col A Col B
1 Header Header
2 value a value a
3 value b value b
4 value c value c
5 value d value d

Based on this example I would want to remove "value d" from Col A only,
but keep "value d" in Col B and so on and so on if I had other values
in row 5 in other Columns after B.



Range("a2:a5").End(xlDown).Delete



bobbo

Need to delete last value in column but not delete entire row
 

wrote:
When using Range("a2:a5").End(xlDown).Delete, it does delete the value
from A5, but then it shifts the value B5 over to cell A5.


bobbo wrote:
wrote:
This little snippet works great if I need to delete the last row, but
how can I tweak it where I need to delete the last value in a column
only and not delete the entire row?

Sub test()
Rows(Range("A2:A5").End(xlDown).Row).Delete

End Sub


Example:
Col A Col B
1 Header Header
2 value a value a
3 value b value b
4 value c value c
5 value d value d

Based on this example I would want to remove "value d" from Col A only,
but keep "value d" in Col B and so on and so on if I had other values
in row 5 in other Columns after B.



Range("a2:a5").End(xlDown).Delete


Range("a2:a5").end(xldown).clear


Charles Chickering

Need to delete last value in column but not delete entire row
 
Range("A2").End(xlDown).Delete Shift:=xlUp

having the "A2:A5" does nothing for you, the "xlDown" is executed from the
first cell in the range that you give it.
--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

When using Range("a2:a5").End(xlDown).Delete, it does delete the value
from A5, but then it shifts the value B5 over to cell A5.


bobbo wrote:
wrote:
This little snippet works great if I need to delete the last row, but
how can I tweak it where I need to delete the last value in a column
only and not delete the entire row?

Sub test()
Rows(Range("A2:A5").End(xlDown).Row).Delete

End Sub


Example:
Col A Col B
1 Header Header
2 value a value a
3 value b value b
4 value c value c
5 value d value d

Based on this example I would want to remove "value d" from Col A only,
but keep "value d" in Col B and so on and so on if I had other values
in row 5 in other Columns after B.



Range("a2:a5").End(xlDown).Delete





All times are GMT +1. The time now is 10:32 AM.

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