excel - Sorting things to match information on a column -
watch example:
i have possible information in first column, second 1 has information of exists phisically. row starting on second column shows information of exists.
is there way sort things out this?
i've tried sortings things out alphabetically, , didn't work demonstrated. note example. in main sheets things not near 1 yet point stands.
i accept either macro or formula answers, thank you.
try this. in vba ide have got tool -> reference , select "microsoft activex data ovjects 2.8 library"
option explicit private sub sortexisting() dim rspossible new adodb.recordset dim rsexists new adodb.recordset dim ws excel.worksheet dim lrow long dim lfind long set ws = application.activesheet 'add fields recordset storing data. can store sums here. rspossible .fields.append "row", adinteger .fields.append ""possible", adchar, 20 .open end rsexists .fields.append "exists", adchar, 20 .fields.append "value1", adchar, 30 .fields.append "value2", adchar, 33 'make fields big need be. .fields.append "value3", adchar, 20 .open end lrow = 1 'loop through , record in columns. while lrow <= ws.usedrange.rows.count rspossible.addnew rspossible.fields("row").value = lrow rspossible.fields("possible").value = ws.range("c" & lrow).value rspossible.update rsexists.addnew rsexists.fields("exists").value = ws.range("d" & lrow).value ws.range("d" & lrow).value = "" rsexists.fields("value1").value = ws.range("e" & lrow).value ws.range("e" & lrow).value = "" rsexists.fields("value2").value = ws.range("f" & lrow).value ws.range("f" & lrow).value = "" rsexists.fields("value3").value = ws.range("g" & lrow).value ws.range("g" & lrow).value = "" rsexists.update lrow = lrow + 1 ws.range("a" & lrow).activate loop if rsexists.eof = false rsexists.movefirst end if 'here loop through existing while rsexists.eof = false "find current existing in th rspossible.filter = "" rspossible.filter = "possible='" & rsexist.fields("exists").value lfind = rspossible.fields("row").value 'write value of existing row of possible ws.range("d" & lfind).value = rspossible.fields("exists").value ws.range("e" & lfind).value = rspossible.fields("value1").value ws.range("f" & lfind).value = rspossible.fields("value2").value ws.range("g" & lfind).value = rspossible.fields("value3").value rsexists.movenext loop end sub
Comments
Post a Comment