Help with a macro!!!!

basserj

New Member
Joined
Dec 5, 2016
Messages
1
Need a macro that compares the location on a spreadsheet and places blanks across the entire row in the sheet if they don"t match up. I have one that does this for A and B but I have to copy and paste the locations in those columns then manually go back and manipulate the the sheet, example:As you can see the 7th row has been moved down to match the 8th. This usually extends from column A to O.


Item numberProduct nameLocationPhysical inventoryCountedItem numberProduct nameLocationPhysical inventoryCount
1Boomer RangBA-01-1-1195.00195.001Boomer RangBA-01-1-1195.00195.00
2Boomer RangBA-01-2-160.0060.002Boomer RangBA-01-2-160.0060.00
3Boomer RangBA-01-2-21,100.001,100.003Boomer RangBA-01-2-21,100.001,100.00
4Boomer RangBA-01-2-46.006.004Boomer RangBA-01-2-46.006.00
5Boomer RangBA-01-2-5500.00500.005Boomer RangBA-01-2-5500.00500.00
6Boomer RangBA-01-3-11,600.001,600.006Boomer RangBA-01-3-11,600.001,600.00
7Boomer RangBA-01-3-23,500.003,500.00
7Boomer RangBA-01-3-31,800.001,800.008Boomer RangBA-01-3-31,600.001,600.00
8Boomer RangBA-01-4-12,200.002,200.009Boomer RangBA-01-4-12,200.002,200.00
9Boomer RangBA-01-4-22,100.002,100.0010Boomer RangBA-01-4-22,100.002,100.00
10Boomer RangBA-01-4-31,500.001,500.0011Boomer RangBA-01-4-31,500.001,500.00
11Boomer RangBA-02-1-1200.00200.0012Boomer RangBA-02-1-1200.00200.00
12Boomer RangBA-02-1-3300.00300.0013Boomer RangBA-02-1-3300.00300.00
13Boomer RangBA-02-2-4800.00800.00



<colgroup><col><col><col><col><col><col><col><col><col><col span="2"></colgroup><tbody>
</tbody>
This is the macro for the A and B columns:
Sub test()
Dim w, n As Long, a As Range, x As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
n = Range("A:B").Find("*", after:=[a1], searchdirection:=xlPrevious, searchorder:=xlByRows).Row
w = Range("A1:B" & n)
Range("AA1:AB" & n) = w
Cells(n + 1, 1) = Chr(255): Cells(n + 1, 2) = Chr(255)
Set a = Cells(1, 1).Resize(n + 1, 2)
a.Resize(, 1).Sort a(1, 1), 1, Header:=xlYes
a.Resize(, 1).Offset(, 1).Sort a(1, 2), 1, Header:=xlYes
Do
x = x + 1
If a(x, 1) > a(x, 2) Then
a(x, 1).Insert xlDown
ElseIf a(x, 1) < a(x, 2) Then
a(x, 2).Insert xlDown
End If
If x > 10 ^ 4 Then Exit Do
Loop Until a(x, 1) = Chr(255) And a(x, 1) = Chr(255)
Cells(x, 1).Resize(1, 2).ClearContents
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub

Any help would be much appreciated!

<colgroup><col><col><col><col><col><col><col><col><col><col span="2"></colgroup><tbody></tbody>
.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
basserj,

Welcome to the MrExcel forum.

This usually extends from column A to O.

If that is so, then a flat text display will probably not fit in the MrExcel display area.


1. Can we see your actual raw data workbook/worksheet?

2. And, in an additional worksheet, can we see what the results (manually formatted by you) should look like?

You can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:

https://dropbox.com
 
Upvote 0

Forum statistics

Threads
1,215,050
Messages
6,122,868
Members
449,097
Latest member
dbomb1414

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