copying data to next available empty columns

themole

Board Regular
Joined
Oct 26, 2009
Messages
96
hi,

sorry if this has been covered before.

i have a table of names (75 in total) and values, every week the values will change on the table. What i am after is a code so that once i click on the control button it will automatically copy and paste the list of names and corresponding values into next available empty columns in spreadsheet.

original list of names range from A4:A78 and values B4:B78. ideally would like to start copying data into columns D:E, leave column F blank then once control button clicked again to start copying into columns G:H, leave column I blank, and so on

hope this sounds straight forward,

cheers
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
Sub v()
Dim col&
col = Cells(1, Columns.Count).End(xlToLeft).Column - 1
Columns(col).Resize(, 2).Copy Columns(col + 3)
End Sub
 
Upvote 0
Hi, thanks for reply.

this works.... but not the way i intended..

i only want to copy data from columns A and B into next empty columns leaving a column blank between results in the process. this is copying data from last column of results into next available column

so basically info in A:B will be copied into D:E, then info from A:B will be copied into G:H...and so on

thanks
 
Upvote 0
Code:
Sub v()
[A:B].Copy Cells(1, Columns.Count).End(xlToLeft)(1, 3).EntireColumn
End Sub
 
Upvote 0
sorry but this seems a step back from the 1st one. this is now just copying column A into column B then C then stopping after that with no copying. the 1st code was spot on apart from wanting to copy the original data in columns A:B into next available blank columns leaving 1 column width between each 2 columns of copied data
 
Upvote 0
Code:
Sub v()
[A:B].Copy Cells(5, Columns.Count).End(xlToLeft)(1, 3).EntireColumn
End Sub
 
Upvote 0
fantastic!

one more quick question...if i was to have maybe 5 columns of data to copy/paste for example(A to E) and still require same process, what would i need to change on the code?
 
Upvote 0
Code:
Sub v()
[A:E].Copy Cells(5, Columns.Count).End(xlToLeft)(1, 3).EntireColumn
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top