Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy/paste in the next column | Excel Programming | |||
Why won't the copy/paste from PDF retain the row/column in excel? | Excel Discussion (Misc queries) | |||
Copy column in Excel and paste horizontally in Word. | Excel Discussion (Misc queries) | |||
Save column J only using copy/paste & temporary copy | Excel Programming | |||
Open file, Copy a column and paste this into a new Excel doc - Pl | Excel Programming |