IF Statements in VB

rwrussell

New Member
Joined
Nov 6, 2002
Messages
1
Trying to pull info out of an excel database and copy to a new spreadsheet skipping over the duplicates in exel the statement would be

=If(activecell = active cell(-1,0), skip down one cell, run imbeded macro to copy row to other sheet)
Then loop

What is the correct VB way of structuring this IF/Then statement

Thanks
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
On 2002-11-07 17:34, rwrussell wrote:
Trying to pull info out of an excel database and copy to a new spreadsheet skipping over the duplicates in exel the statement would be

=If(activecell = active cell(-1,0), skip down one cell, run imbeded macro to copy row to other sheet)
Then loop

What is the correct VB way of structuring this IF/Then statement

Thanks

I guess it would depend on how many columns you have, and do you need to make sure that every column in the row is a duplicate. I also assume that you have sorted your data appropriately.

Have you tried the Advanced Filter (Data-Filter-Advanced Filer)? You can get unique values only, and you can copy to another location. Unfortunately, you cannot copy to another sheet, let alone another workbook. But you could copy to another location on the current sheet, then cut and paste to the other workbook (you could automate this in VBA also - try recording it then changing appropriately).

If you really want to go row by row, let us know how many columns you are comparing for duplicates, and I (or someone else) can help you.

If I'm not being clear about the number of columns, consider the following example (each column is separated by a space):

AA 12 Bobby
AA 12 Cindy
AB 34 Sally
AB 34 Sally
AC 55 Fred

in the above example, there's really only 1 line that is duplicated...

-rh
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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