Turn Excel range into VBA string

前端 未结 7 1729
野性不改
野性不改 2020-11-30 11:51

I would like to turn values in given range into VBA string where original cell values are separated by any chosen column delimiter and row delimiter. Delimiters could be one

相关标签:
7条回答
  • 2020-11-30 12:33
    Sub aquatique()
    dim a(),s$,i&,j&:a=selection.value
    for i=1 to ubound(a)
    for j=1 to ubound(a,2)
        if j=1 then
            if i=1 then
                s=  a(i,j)
            else
                s=s &"@" & vbnewline & a(i,j)
            end if
        else
            s=s &";" & a(i,j)
        end if
    next
    next
    end sub
    

    simple but does the job. Slow on huge ranges, you'd need to use "join"

    0 讨论(0)
提交回复
热议问题