excel vba - Concatenate two selected cells and delete -


i have data in column 1000 rows of data. need concatenate 2 selected cells. example, data in user selected cells a10 & a11 gets concatenated in cell a10. after need clear content of cell a11.

the code below job of concatenation, , puts data in a10. not clear contents of a11 cell data. need clear a11 cell contents.

any appreciated.

option explicit sub mergestems()    dim colfirst long   dim collast long   dim joinedvalue string   dim rowcrnt long   dim rowfirst long   dim rowlast long      rowfirst = selection.row      rowlast = rowfirst + selection.rows.count - 1      colfirst = selection.column     collast = colfirst + selection.columns.count - 1      if colfirst <> 1 or collast <> 1       call msgbox("please select range within column ""a""", vbokonly)       exit sub     end if      worksheets("sheet1")      ' worksheet of choice.       joinedvalue = .cells(rowfirst, "a").value       rowcrnt = rowfirst + 1 rowlast         joinedvalue = joinedvalue & " " & .cells(rowcrnt, "a").value       next       .cells(rowfirst, "a").value = joinedvalue     end    end sub 

add before "end with"

.cells(rowfirst + 1, 1).resize(selection.rows.count - 1, 1).clearcontents 

note: dont miss out dot @ beginning

edit: try now. tested on pc , worked


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -