View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] johnhildreth@citynet.net is offline
external usenet poster
 
Posts: 43
Default Macro for Editing Data

The following worked for me. Give it a try. The locations are hard
coded in, so you may need to alter the cell references to match your
needs.

Sub test()

Dim val1 As String
Dim val2 As String
Dim lastcell As Long

lastcell = Range("A65536").End(xlUp).Row

For i = 1 To lastcell
val1 = Cells(i, 1).Value
val2 = Cells(i, 2).Value
If val1 < val2 Then
Range(Cells(i, 2), Cells(i, 3)).Insert (xlShiftDown)
End If
Next i

End Sub

HTH,
John


On Feb 18, 7:21 pm, wrote:
I have three columns of data - the first is a master list of
countries, the second an incomplete list that has a third column
referring to this. I want to somehow create a script to match up the
second and third columns with the first. For example:

Row 1: America - America - 3
Row 2: Belgium - Belgium - 5
Row 3: Belize - Canada - 10
Row 4: Canada - Cape Verde - 7
Row 5: Cape Verde, etc...

The numbers in the third column don't have any significance. Since
the first column is complete, I want to shift the second and third
columns down a row after "Belgium" so there is a blank after Belize,
and the next row lines up - (it says Canada in all rows). So it
should become:

Row 1: America - America - 3
Row 2: Belgium - Belgium - 5
Row 3: Belize - BLANK
Row 4: Canada - Canada - 10
Row 5: Cape Verde - Cape Verde - 7
etc....

I have LOTS of columns and rows of this data, and I need to match them
all up. Is there a good way to do this? Or do I just have to do it
by hand??

Thanks SO much for your help!

Will