excel - Copy Range with VBA to clipboard -


so here i'm trying do. have sheet parse cisco router interface errors between snapshots create summary of how many packets , errors on each interface. have button tied macro executes copy summary itself.

x1 = cells(2, 6).value y1 = cells(3, 6).value x2 = cells(4, 6).value y2 = cells(5, 6).value  activesheet.range(cells(y1, x1), cells(y2, x2)).copy 

each of cells listed have value of row or column sections copied correctly. x2's cell set based on how many interfaces can change selected range.

my problem lies wanting copy , latest snapshot (which in cell directly above summary section) together. want place snapshot under summary ideally when copied clipboard. i've imagine i'll need convert range string add both strings , put in clipboard. can't range convert can put in clipboard. code i'm using below found on here converting range string array , putting strings clipboard. can't figure out how string array clipboard errors out 'object required'. appreciated.

x1 = cells(2, 6).value y1 = cells(3, 6).value x2 = cells(4, 6).value y2 = cells(5, 6).value     ' values variant array dim variantvalues variant variantvalues = activesheet.range(cells(y1, x1), cells(y2, x2)).value  ' set string array them dim stringvalues() string redim stringvalues(1 ubound(variantvalues, 1), 1 ubound(variantvalues, 2))  ' put them in there! dim columncounter long, rowcounter long rowcounter = ubound(variantvalues, 1) 1 step -1    columncounter = ubound(variantvalues, 2) 1 step -1        stringvalues(rowcounter, columncounter) = cstr(variantvalues(rowcounter, columncounter))    next columncounter next rowcounter  ' return string array rangetostringarray = stringvalues  set msforms_dataobject = createobject("new:{1c3b4210-f441-11ce-b9ea-00aa006b1a69}") msforms_dataobject.settext rangetostringarray.value msforms_dataobject.putinclipboard set msforms_dataobject = nothing 

i solved tip off of slai.

sub copycompsnap()      x1 = cells(2, 6).value     y1 = cells(3, 6).value     x2 = cells(4, 6).value     y2 = cells(5, 6).value      dim dataobj msforms.dataobject      set dataobj = new msforms.dataobject      activesheet.range(cells(y1, x1), cells(y2, x2)).copy     dataobj.getfromclipboard      on error resume next      string1 = dataobj.gettext(1)      if err.number <> 0       string1 = "clipboard empty"     end if     activesheet.range("b5").copy     dataobj.getfromclipboard      on error resume next      string2 = dataobj.gettext(1)      if err.number <> 0       string2 = "clipboard empty"     end if     strcopy = string1 & string2     set msforms_dataobject = createobject("new:{1c3b4210-f441-11ce-b9ea-00aa006b1a69}")     msforms_dataobject.settext strcopy     msforms_dataobject.putinclipboard     set msforms_dataobject = nothing  end sub 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -