Comparing and Sorting strings within the same row.

alexm25

New Member
Joined
Jul 7, 2010
Messages
2
Hi,

I am trying to write a macro that will take two strings, check to see if they both contain the relevant information I am looking for, and then cut/paste the string with the largest "value" to a cell within that same column. I.E. I have a URL (column A) and a Printer name (Column B) in row i, and I want to take the printer type and ppm and move them into row i, the problem being that I have multiple entries for printer type and ppm, and need to select the correct one and move it into the correct row.



My algorithm is this:
if row has URL in col A and printer name in col B then,
cut/paste cell: col D,row j to col D row i, where the ith row is the static row containing the URL and printer name.
Then, take cell col E row j, and col E row k (k = j+ 1) assign them to two different strings, and compare them, take the larger of the strings (value not length) and input it to cell, col E row i. repeat this last step until the next blank cell in col D, then
delete all cells that have been compared but are not the maximum.

my code follows:

Dim i As Integer
Dim j As Integer
Dim k As Integer
For i = 11 To 6000
If Not (Range("B" & i) & Range("A" & i) = "") Then
Do
j = i
k = j + 1
Dim temp As String
Dim perm As String
Range("D" & j).Cut (Range("D" & i))
temp = Range("E" & j)
perm = Range("E" & k)
If (temp Like "*ppm" And perm Like "*ppm") Then
Range("E" & i) = perm
j = j + 1
While Not (Range("D" & i) = "")
End If
Next i
End Sub


all help will be appreciated and I hope my post was not too confusing
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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