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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Russell Hauf

MrExcel MVP
Joined
Feb 10, 2002
Messages
1,611
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
 

Forum statistics

Threads
1,144,217
Messages
5,723,063
Members
422,477
Latest member
pete101

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
Top