Macro help

zerro

New Member
Joined
Nov 6, 2008
Messages
44
This macro worked great in Office 2003 but won't work in Office 2010

Compile error
Variable not Defined.
Highlighting cell in below line

For Each Cell In Selection

Can this be fixed.

Thank you.


Code:
Sub StripRowDuplicates()
Do Until ActiveCell = ""
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
For Each Cell In Selection
If WorksheetFunction.CountIf(Selection, Cell) > 1 Then
Cell.ClearContents
Else
End If
Next Cell
On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
ActiveCell.Range("A2").Select
Loop
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Do you have the "Option Explicit" command at the very top of your modules? If so, you need to declare all your variables before using them (which is actually a good programming practice anyway).

So place this line after your "Sub" line and before your "Do" command:
Code:
Dim cell as Range
 
Upvote 0
Thank you Joe4.
Yes I had Option Explicit on top with another macro.
The macro works fine without it
And also with your code.
Thank you so much.
 
Upvote 0
The thing to remember is if you use the Option Explicit command, you will need to declare all your variables before you use them.

Many programmers do so on purpose, as it can help with error debugging (helps identify typos, variable name changes, etc).
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top