excel - VBA Loop within a loop -


im looking work in data

say have

4 rows first allways starts uo2 in column below s72's (i.e reason uo2) need have reference s72s stands way link s72 uo2 knowing s72 directly below u02 untill next uo2

what need duplicate uo2 entry every line s72 relates shift s72 across dont have duplicates

╔════╦══════════════╦══════╗ ║ tr ║  community   ║ 210  ║ ╠════╬══════════════╬══════╣ ║uo2 ║ -----------  ║ 5636 ║ ║s72 ║ reason       ║  148 ║ ║s72 ║ reason       ║  101 ║ ║s72 ║ reason       ║  959 ║ ╚════╩══════════════╩══════╝ 

what need macro

╔════╦══════════════╦══════╗ ║ tr ║  community   ║ s72  ║ ╠════╬══════════════╬══════╣ ║uo2 ║ -----------  ║reason║ ║uo2 ║ -----------  ║reason║ ║uo2 ║ -----------  ║reason║ ║uo2 ║ -----------  ║reason║ ╚════╩══════════════╩══════╝ 

there can multiple reasons s72 , reference stop delcaration of uo2

if understand, you're looking turn column column uo2's , move s72 data on 2(?) columns column c.

if that's right, need 2 long variables control looping, 1 current row being looked at, , other reference uo2 use. ex:

dim long dim j long  'start them @ same point, assumes row 1 header = 2 j = 2  'assuming once column blank, have no more data process while range("a" & i).value <> ""     'check uo2     if range("a" & i).value = "uo2" 'adjust condition appropriately         'update j         j =     else         'shift data on (if there data right of column c you'll         ' need tweak code not overwrite         range("c" & i).value = range("b" & i).value          'copy down uo2 info         range("a" & i).value = range("a" & j).value         range("b" & i).value = range("b" & j).value     end if      'increment no matter case     = + 1 loop  'you need loop through , delete rows have uo2 data (i.e. column c ' blank), shouldn't difficult 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -