ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to enhance this macro (really short) (https://www.excelbanter.com/excel-programming/276536-re-how-enhance-macro-really-short.html)

Bob Phillips[_5_]

how to enhance this macro (really short)
 
Deno,

Untested, but try

Sub Macro1()
For Each rw In Worksheets(1).Cells(Selection.Column,
1).CurrentRegion.Rows
this = rw.Value
If this = last Then rw.Clear
last = this
Next
End Sub


--

HTH

Bob Phillips

"DenoxiS" wrote in message
om...
Hi,

I have following macro to clean up the repeating lines on a column:

Sub Macro1()
For Each rw In Worksheets(1).Cells(1, 1).CurrentRegion.Rows
this = rw.Cells(1, 1).Value
If this = last Then rw.Cells(1, 1).Clear
last = this
Next
End Sub

It works for the first column of the first worksheet. I couldn't refer
to the current column of the current worksheet. How can I modify it so
my macro work on the selected/active/higlighted column of the current
worksheet?




Bob Phillips[_5_]

how to enhance this macro (really short)
 
Should have tested it. Try this version

cRows = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
For Each rw In Range(Cells(1, ActiveCell.Column), Cells(cRows,
ActiveCell.Column))
this = rw.Value
If this = last Then rw.Clear
last = this
Next


The sheet to modify needs to be active for this.

--

HTH

Bob Phillips

"Bob Phillips" wrote in message
...
Deno,

Untested, but try

Sub Macro1()
For Each rw In Worksheets(1).Cells(Selection.Column,
1).CurrentRegion.Rows
this = rw.Value
If this = last Then rw.Clear
last = this
Next
End Sub


--

HTH

Bob Phillips

"DenoxiS" wrote in message
om...
Hi,

I have following macro to clean up the repeating lines on a column:

Sub Macro1()
For Each rw In Worksheets(1).Cells(1, 1).CurrentRegion.Rows
this = rw.Cells(1, 1).Value
If this = last Then rw.Cells(1, 1).Clear
last = this
Next
End Sub

It works for the first column of the first worksheet. I couldn't refer
to the current column of the current worksheet. How can I modify it so
my macro work on the selected/active/higlighted column of the current
worksheet?







All times are GMT +1. The time now is 03:50 AM.

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