i using function saw here on stackoverflow:
function extractelement(txt, n, separator) string extractelement = split(application.trim(txt), separator)(n - 1) end function
it spliting array of data, this:
srn lmdscandata sra lmdscandata 1 1 f97bbf 0 0 6d2a 6d2d 71f5a0fa 71f5fd85 0 0 7 0 0 1388 168 0 1 dist1 3f800000 00000000 d9490 1388 5 6e2 6dc 6e3 6ed 6e1 0 0 0 0 0 0
but when tried increase amount of data:
srn lmdscandata sra lmdscandata 1 1 f97bbf 0 0 fcdf fce2 9dc90606 9dc9637b 0 0 7 0 0 1388 168 0 1 dist1 3f800000 00000000 c3500 1388 3d 525 50b 518 508 51d 50a 51a 502 514 50f 502 51c 50e 51c 50e 4ff 509 505 50b 4f9 505 51b 513 516 501 50f 509 4fe 505 508 50c 507 50c 50e 51a 511 514 528 511 519 524 52e 526 522 524 535 534 52e 527 52f 52e 53d 52f 550 535 547 548 559 551 557 558 0 0 0 0 0 0
an error occuring , vba returns error window , no data splitted. how can fix it?
this full code, coding test sensor output, receive important data in hex&ascii , transform dec , make graphs. function convert values. if can give tips on sub, appreciate.
sub ler() dim ncell dim varr, col dim counter, elem_end integer dim rng1, rng2 string set ascii = thisworkbook.worksheets("ascii") set medidas = thisworkbook.worksheets("medidas") 'valor da última linha preenchida da coluna a' ncell = ascii.range("a65536").end(xlup).row 'número de elementos' elem_end = ascii.range("b" & ncell).value counter = 1 elem_end counterplus = counter + 2 varr = split(cells(1, counterplus).address(true, false), "$") col_letter = varr(0) col = col_letter let rng1 = col & ncell let rng2 = "a" & ncell ascii.range(rng1).numberformat = "@" ele = extractelement(ascii.range(rng2), counter, " ") ascii.range(rng1).formular1c1 = ele next ascii.range(cells(ncell, 1), cells(ncell, counterplus)) set dist = .find("dist1", lookin:=xlvalues) if not dist nothing firstaddress = dist.address dist1 = firstaddress set dist = .findnext(dist) loop while not dist nothing , dist.address <> firstaddress end if end data_col = ascii.range(dist1).column + 5 data_num = ascii.cells(ncell, data_col).value dec_num = clng("&h" & data_num) medidas.range("a" & ncell).value = dec_num counter2 = 1 data_num asc_value = ascii.cells(ncell, data_col + counter2).value dec = clng("&h" & asc_value) medidas.cells(ncell, counter2 + 1).value = dec next end sub
in column b, there function calculates number of elements of data in column a
you need declare variables, getting type mismatch, @ least first needs declared.
function extractelement(txt string, n long, separator string) string extractelement = split(application.trim(txt), separator)(n - 1) end function
Comments
Post a Comment