Copy & Paste to the next empy cell. (Vba Code not Working)

Domcast

New Member
Joined
Apr 19, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I created a macro button to copy a cell and paste value in another sheet but it just replaces the value in the same cell on the other sheet. I need it to count the columns and continue to paste the value in the next cell to the right. The code below is what i currently using to make it happen, this worked on prior spreadsheets I have done but not sure what I'm doing wrong. Please Help..



Col = Sheet3.Cells(11, 11).CurrentRegion.Columns.Count + 1
Sheet3.Cells(11, 11) = Sheet2.Range("E10")
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi & welcome to MrExcel.
How about
VBA Code:
col = Sheet3.Cells(11, Columns.Count).End(xlToLeft).Offset(, 1).Column
Sheet3.Cells(11, col).Value = Sheet2.Range("E10").Value
 
Upvote 0
Cross posted Copy & Paste to the next empy cell. (Vba Code not Working) - OzGrid Free Excel/VBA Help Forum
and Copy & Paste to the next empy cell. (Vba Code not Working)

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
.
This macro works, assuming on the PASTE Sheet cell J11 has some data in it.

VBA Code:
Sub CopyRange()

Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long

Set source = Sheets("Sheet1")  'change sheet name to suit
Set destination = Sheets("Sheet2")  'change sheet name to suit
'emptyColumn = 11
'find empty Column (actually cell in Row 1)'
emptyColumn = destination.Cells(11, destination.Columns.Count).End(xlToLeft).Column
If emptyColumn > 1 Then
emptyColumn = emptyColumn + 1
End If

source.Range("E10").Copy destination.Cells(11, emptyColumn)

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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