ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Urgent-formating of columns (https://www.excelbanter.com/excel-programming/288593-urgent-formating-columns.html)

Pogas

Urgent-formating of columns
 
Dear all
I am a newbie,and looking urgently for help.Any comments will be appreciate
I have two columns in a spreadsheets as below.I want to match these two columns and insert a blank cell in column No2 where the two values in the cells dont match.For example I want to insert a blank cell in column before A2 in No2 and one blank cell after A2 to match A3 etc .How do I go about this?
No1 No
A1 A
A2 A
A3 A
A4
A5
A6

After formatin
No1 No
A
A2 A
A
A4 A
A
A6 A

Thank
Poga


Rob van Gelder[_4_]

Urgent-formating of columns
 
Pogas,

You might be better off using a VLOOKUP function to lookup your values.

If not, then this procedure should work.

Sub test()
Dim i As Long, lngLastRow As Long

With Sheet1
lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lngLastRow
If .Cells(i, 1).Value < .Cells(i, 2).Value Then .Cells(i,
2).Insert xlShiftDown
Next
End With
End Sub


Rob


"Pogas" wrote in message
...
Dear all,
I am a newbie,and looking urgently for help.Any comments will be

appreciated
I have two columns in a spreadsheets as below.I want to match these two

columns and insert a blank cell in column No2 where the two values in the
cells dont match.For example I want to insert a blank cell in column before
A2 in No2 and one blank cell after A2 to match A3 etc .How do I go about
this??
No1 No2
A1 A2
A2 A4
A3 A6
A4
A5
A6


After formating
No1 No2
A1
A2 A2
A3
A4 A4
A5
A6 A6

Thanks
Pogas





All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com