Need help with comparison vba code


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

New Reply
Thread Tools Rate Thread Display Modes
  #1  
Unread 16th February 2012, 19:37
Audioboxer's Avatar
Audioboxer Audioboxer is offline
Junior Member
MS Office Version: Ms Office 2010
MS Office Skill Level: No VBA Skills
 
Join Date: Feb 2012
Location: Manchester, new Hampshire
Posts: 2
Posts Per Day: 0.00
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Audioboxer is on a distinguished road
Default Need help with comparison vba code
     Excel: VBA   


Hi everyone,

I found this code below to compare columns a and d. The second version I added (colorduplicates2) I added Two textboxes so that I can input the range i want to compare in the however It's not Working how I have it. Any ideas how to manipulate it so it will pull whats in the text boxes? Thank you!

VBA CODE:
Sub ColorDuplicates() 
     
    For i = 1 To Range("B65536").End(xlUp).Row 
        If Application.WorksheetFunction.CountIf(Range("A:A"), Range("D" & i)) = 1 Then 
            With Range("D" & i).Font 
                .ColorIndex = 3 
                .Bold = True 
            End With 
        End If 
    Next i 
    For i = 1 To Range("A65536").End(xlUp).Row 
        If Application.WorksheetFunction.CountIf(Range("D:D"), Range("A" & i)) = 1 Then 
            With Range("A" & i).Font 
                .ColorIndex = 3 
                .Bold = True 
            End With 
        End If 
    Next i 
     
     
End Sub 
 
 
 
Sub ColorDuplicates2() 
     
    For i = 1 To Range("B65536").End(xlUp).Row 
        If Application.WorksheetFunction.CountIf(Range("TextBox1.Value"), Range("LEFT(TextBox2,1)" & i)) = 1 Then 
            With Range("LEFT(TextBox2,1)" & i).Font 
                .ColorIndex = 3 
                .Bold = True 
            End With 
        End If 
    Next i 
    For i = 1 To Range("A65536").End(xlUp).Row 
        If Application.WorksheetFunction.CountIf(Range("TextBox2.Value"), Range("LEFT(TextBox1,1" & i)) = 1 Then 
            With Range("LEFT(TextBox1,1" & i).Font 
                .ColorIndex = 3 
                .Bold = True 
            End With 
        End If 
    Next i 
     
     
     
End Sub 


- via Tapatalk.


Last edited by RoyUK; 16th February 2012 at 19:43.
The Code Cage Advertisment
Advertisement
  #2  
Unread 16th February 2012, 19:45
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,678
Posts Per Day: 1.23
My Top Tip Count: 4
Thanks to others: 2
Thanked 194 Times in 192 Posts
Reputation: 3305 (65) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Need help with comparison vba code

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me

  #3  
Unread 16th February 2012, 20:10
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,678
Posts Per Day: 1.23
My Top Tip Count: 4
Thanks to others: 2
Thanked 194 Times in 192 Posts
Reputation: 3305 (65) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Need help with comparison vba code

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me

The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!

  #4  
Unread 17th February 2012, 20:13
Audioboxer's Avatar
Audioboxer Audioboxer is offline
Junior Member
MS Office Version: Ms Office 2010
MS Office Skill Level: No VBA Skills
 
Join Date: Feb 2012
Location: Manchester, new Hampshire
Posts: 2
Posts Per Day: 0.00
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Audioboxer is on a distinguished road
Default Re: Need help with comparison vba code

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






  #5  
Unread 18th February 2012, 09:11
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,678
Posts Per Day: 1.23
My Top Tip Count: 4
Thanks to others: 2
Thanked 194 Times in 192 Posts
Reputation: 3305 (65) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Need help with comparison vba code

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me

The Code Cage Advertisment
Advertisement
New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
code, comparison, vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 04:43.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University