View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default vba excel copy paste 1 column to 1 column

sample image
https://i.imgur.com/l32T2VM.jpg

code vba excel

Sub pasteoneonecolumn()
Dim lngRow As Long, objCOMAddin As COMAddIn
lngRow = 1
With ActiveSheet
For Each objCOMAddin In Application.COMAddIns
.Cells(lngRow, "E").Value = .Cells(lngRow, "A").Value
.Cells(lngRow, "F").Value = .Cells(lngRow, "B").Value
.Cells(lngRow, "G").Value = .Cells(lngRow, "C").Value
lngRow = lngRow + 1
Next objCOMAddin
End With
End Sub




for ask

why not all, only E1:E7
only up to 7 columns, how can I get all the columns?
anyone can help for vba excel that ?


Your loop counter is the number of COMAddins, NOT the number of rows (A:C)
containing values. Ergo, the loop stops when it runs out of COMAddins!

Not sure what your logic is (if any at all) for looping the COMAddins
collection, or what that has to do with the values shown in your link. Please
explain better what it is EXACTLY that you are trying to accomplish!

Otherwise...

Sub CopyCols()
With ActiveSheet
.Cells(1, 1).Resize(.UsedRange.Rows.Count, 3).Copy .Cells(1, "E")
End With 'ActiveSheet
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion