ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba excel copy paste 1 column to 1 column (https://www.excelbanter.com/excel-programming/454581-vba-excel-copy-paste-1-column-1-column.html)

[email protected]

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 ?

GS[_6_]

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

[email protected]

vba excel copy paste 1 column to 1 column
 
gs, thank you for answering,
I have tried the VBA code, but I need the same function as the VBA code
because I need colomn to colomn, one one goes to colomn. sample


if the code you give is like copying = E1: H11 and paste it into A1

what I want is the same as copying E1 to A1, E2 to A3, & F1 to b1, F2 to b2.

[email protected]

vba excel copy paste 1 column to 1 column
 
gs, thank you for answering,
I have tried the VBA code, but I need the same function as the VBA code
because I need colomn to colomn, one one goes to colomn. sample

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

if the code you give is like copying = E1: H11 and paste it into A1


but what I want is the same as copying E1 to A1, E2 to A2, & F1 to b1, F2 to b2.

[email protected]

vba excel copy paste 1 column to 1 column
 
gs, thank you for answering,
I have tried the VBA code, but I need the same function as the VBA code
because I need colomn to colomn, one one goes to colomn. sample

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

if the code you give is like copying = E1: H11 and paste it into A1


but what I want is the same as copying E1 to A1, E2 to A3, & F1 to b1, F2 to b2.

[email protected]

vba excel copy paste 1 column to 1 column
 
gs, thank you for answering,
I have tried the VBA code, but I need the same function as the VBA code
because I need colomn to colomn, one one goes to colomn. sample

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

if the code you give is like copying = E1: H11 and paste it into A1


but what I want is the same as copying E1 to A1, E2 to A2, & F1 to b1, F2 to b2.

is there another solution for VBA?

GS[_6_]

vba excel copy paste 1 column to 1 column
 
Oh, you mean go the other way?

Sub CopyCols()
With ActiveSheet
.Cells(1, "E").Resize(.UsedRange.Rows.Count, 3).Copy .Cells(1, "A")
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

[email protected]

vba excel copy paste 1 column to 1 column
 
Gs can u try

I tried it and it's not like my VBA code function.

can it? try downloud file

https://www.sendspace.com/file/hhkf5h

addin setup
and try excel name comaddins
click on and check google sheet

try click vba me and try vba you try
and check whether the google sheet matches what is issued

[email protected]

vba excel copy paste 1 column to 1 column
 
Gs im try code

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

the results
https://i.imgur.com/8BHhONu.jpg


im try code

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

the results

https://i.imgur.com/EromfU4.jpg


Do you have a solution?


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com