Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Macro Error Please help

It works for me if you correct for the word wrap. The
following line should all be in one row:

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

If the above code was not corrected for word wrap it
should have been highlighted with red font. Was this not
the case with you ???

Although there seems nothing wrong with the code, you can
remvove all ActiveSheet references since the active sheet
is the default when a range is not qualified. Suggested
is as follows. Correct for the word wrap.

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

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

Regards,
Greg


-----Original 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/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Macro 'Automation error' with ChemOffice Excel macro Stew Excel Programming 0 October 27th 03 08:26 PM
Macro Security Error No Macro Val Steed Excel Programming 1 September 10th 03 06:58 PM


All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"