ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Error Please help (https://www.excelbanter.com/excel-programming/295686-re-macro-error-please-help.html)

Cecilkumara Fernando[_2_]

Macro Error Please help
 
bkbri,
change
Set ColAValues=ActiveSheet.Range("A1:A" &
ActiveSheet.Range("A65536").End(xlUp).Row)
to
Set ColAValues=ActiveSheet.Range("A1:A" & _
ActiveSheet.Range("A65536").End(xlUp).Row)
to run the macro
from your worksheet
ToolsMacro(select the macro you want run and click run)
Cecil

"bkbri " wrote in message
...
Hello,

When I add this Macro script to excel work sheet I get a Syntax error
could someone please help me identify whats wrong with this script.

Sub Sample()
Set ColAValues = ActiveSheet.Range("A1:A" &
ActiveSheet.Range("A65536").End(xlUp).Row)
ColBLastRow = ActiveSheet.Range("B65536").End(xlUp).Row

For i = ColBLastRow To 1 Step -1
CurrentValue = ActiveSheet.Cells(i, 2).Value
For Each Cell In ColAValues
If Cell.Value = CurrentValue Then
ActiveSheet.Cells(i, 2).Delete shift:=xlUp
End If
Next Cell
Next i
End Sub

Its supposed to check columns B and delete any value it finds that
match in Column A

Heres an example...

___A___B__
1.| N | H |
2.| B | I |
3.| C | J |
4.| D | K |
5.| E | L |
6.| F | M |
7.| G | N |<--- N found deleting duplicate in cell A1


Thanks,
Brian


---
Message posted from http://www.ExcelForum.com/




bkbri[_11_]

Macro Error Please help
 
Thanks for the help

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:12 PM.

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