vba - Concatenate every other row in Excel -


i have excel sheet looks this:

3  | latitude | 46.142737  3  | longitude| -57.608968  8  | latitude | 43.142737  8  | longitude| -52.608968  15 | latitude | 41.142737  15 | longitude| -59.608968 

i need end result this:

3  | 46.142737, -57.608968  8  | 43.142737, -52.608968  15 | 41.142737, -59.608968 

it can concatenated based on every other row, or based on integer value in first column.

vba suggestions? thank you.

edit: there no actual "|" in excel sheet. "|" meant visual cue representing new column.

you read data array , write range

original data:
enter image description here

result:
enter image description here

code:

sub example()     dim long     dim x long     dim arry variant      redim arry(1 2, 1 1) variant      = 1 activesheet.usedrange.rows.count         if cells(i, 1).row mod 2 = 1             x = x + 1              redim preserve arry(1 2, 1 x) variant             arry(1, x) = cells(i, 1).value             arry(2, x) = cells(i, 3).value & ", " & cells(i + 1, 3).value         end if     next      arry = worksheetfunction.transpose(arry)     sheets("sheet2").select     range(cells(1, 1), cells(ubound(arry), ubound(arry, 2))).value = arry end sub 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -