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
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