Gentlemen and Ladies:
a quick question....i have an excel sheet, with two columns having numeric content.
I want to compare every row from column B against the whole column A to scan if its in that list...if it is, then it should be placed in column C, and if its not, thenin Column D...you get the idea.
Other solution might be, if I can scan for duplicate rows in column A and delete them....does anyone have any scripts or any code that might help me out?
hi
chk the code..
as im also new to VB ,i might used more number of variables
it might also possible that total procedure that i fallowed was wrong..
but finally what i get was xtly what u want..
thanx ®ards
anu..
PS: Please rate this post..
VB Code:
Private Sub CommandButton1_Click()
Dim x As Integer, y As Integer
Dim flag As Boolean
Dim Cincr As Integer 'if u want u can use this or u can directly
Dim Dincr As Integer 'use x also
Cincr = 1
Dincr = 1
For x = 1 To 23
flag = False
For y = 1 To 23
If Range("b" & x & "").Value = Range("a" & y & "").Value Then
How should I use this code? do i need to create a form for that?
I believe I will have to create a macro..so, what would the steps be...create a macro, lets say ABC, and simply paste this code in there?
1. Looking at a spreadsheet, pick menu Tools -> Macro -> Visual Basic Editor
2. You should be in VBE screen. Pick menu Insert -> Module
3. Paste the code above into the main screen. You can rename the sub to something else if you like, let's say ABC
4. Go back to the spreadsheet window and pick View->Toolbars->Forms. The Forms toolbar should now be visible
5. Click the botton icon on the toolbar, then drag a rectangle on your spreadsheet with the cursor to create a button. A window pop's up asking you to pick a macro. Choose ABC (or whatever name you used) and click OK
6. Close the toolbar (x in upper right hand corner)
7. Clicking the button you just created executes the macro
VBAhack
Instead of using a button, you can also (from spreadsheet menu) pick Tools->Macro->Macros, pick the name of the macro, then click Run. Also, you can use forms (Userform in VBAspeak) if you want, but the button is much more simple if all you want to do is execute a macro.
Last edited by VBAhack; May 25th, 2005 at 02:02 PM.
Code works great...however, does anyone know of any formula that i can use to select the cells and compare every row (every value) in column B to all the rows (all the values) in Column A and put the unique rows from col B in col C.
I had a spreadsheet earlier with this embedded formula, but I seem to have lost it. If anyone could come up with such a formula..that'd be great.
Code works great...however, does anyone know of any formula that i can use to select the cells and compare every row (every value) in column B to all the rows (all the values) in Column A and put the unique rows from col B in col C.
I had a spreadsheet earlier with this embedded formula, but I seem to have lost it. If anyone could come up with such a formula..that'd be great.
Thanks!!
By compare whay do you mean?
And what result are you intending to add to column C? The average of the two, the mean...?
By Comparing I mean that lets consider we have two columns --col A and col B.
Code:
Col A Col B Col C Col D
10 20
20 30
30 35
40 40
Now, I want to compare every element of Col B to Col A. If any element of Col B is not found in Col A, then that element should be placed in Col C. Essentially I want to find out the unique elements in Col B that are not found in Col A.
In the abolve example, I should see 35 placed in Col C.
One which checks from column 1 in column two (make sure the ranges are static ($)), and one that does the reverse will need the columns reordered or a copy of the column.
Attached is a .xls file demonstarting this. D/l and rename
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
One which checks from column 1 in column two (make sure the ranges are static ($)), and one that does the reverse will need the columns reordered or a copy of the column.
Attached is a .xls file demonstarting this. D/l and rename
yea...this works....thanks a lot for your help!
Is there any other excel formula that can also be used to do the kind of comparison I want? I know for sure there is, as I had an excel earlier that did it, but i somewhoe managed to lose it. if someone knows some other excel formula, that'd be great to know as well!
this may not be the best way of doing it, but it certainly works
VB Code:
myrow = 2
mytargrow = 2
Do While Not Range("b" & myrow) = isNothing
myval = Range("b" & myrow)
f = False
On Error Resume Next
f = Range("A1:A20").Find(What:=myval, LookIn:=xlValues).Activate
If f = False Then Range("c" & mytargrow).Value = myval: mytargrow = mytargrow + 1
On Error GoTo 0
myrow = myrow + 1
Loop
pete
Hey pete...I appreciate your effort in writing/finding this code for this issue...however, i already have a code submitted above, that works correctly. Im looking to find some built in excel formula that would help me in getting the results im looking for.
I think there is no need to use macros to find duplicate values. If you want you can use it. You can use the excel formulas to do that.
Code:
--------------------------------------------
Dates in column A Text in Column B
--------------------------------------------
03/10/2003 | AAA
03/15/2003 | BBB
03/20/2003 | CCC
03/25/2003 | AAA
03/30/2003 | BBB
04/04/2003 | CCC
03/25/2003 | AAA
03/30/2003 | BBB
04/04/2003 | CCC
03/25/2003 | AAA
03/30/2003 | BBB
04/04/2003 | CCC
Enter the formula : =A1&B1 to cell C1 and copy / paste the formula to cells C2:C12
Enter the formula : =IF(COUNTIF($C$1:C1,C1)>1,"Duplicate","Unique")
to cell E1 and copy / paste the formula to cells E2:E12
You can change the above formula as per your need.
Thanks,
CS.
Last edited by cssriraman; Jun 23rd, 2005 at 11:56 AM.