Copy Cells to next blank column in another sheet

bdadswell

Board Regular
Joined
Sep 23, 2007
Messages
85
Hello;

I have a sheet where I want to take B4:B12 and have a macro that copies those cells into another sheet, row 3, but to the next blank column. So if the last time the user ran the macro, it went into column "B", the next time it should go to column "C" and so on...

Any ideas?

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,
You could try a count function on row 1 to find your last cell in row 1 that has data, add "1" to it and use that as your location reference for your past.


See if this does what you were looking for:

Code:
[FONT=Calibri]Sub Macro1()
Dim BlankC As Variant
Sheets("Sheet2").Activate
BlankC = Application.WorksheetFunction.CountA(Rows(1))+1
    Range("Sheet1!B4:B12").Copy
    Sheets("Sheet2").Activate
    Cells(1, BlankC).Select
    ActiveSheet.Paste
End Sub[/FONT]
 
Upvote 0
Which line of the code are you getting the error on?

Here's the updated code:

Sub Macro1()
Dim BlankC As Variant
Sheets("Weekly_Report").Activate
BlankC = Application.WorksheetFunction.CountA(Rows(1)) + 1
Range("Weekly_Report!B4:B12").Copy
Sheets("Week_Over_Week").Activate
Cells(1, BlankC).Select
ActiveSheet.Paste
End Sub

I'm getting a "400" error now - I fixed the other error.
 
Upvote 0
OK - I moved it - it kind of works - it's putting the data into A1 in the new sheet, overwriting the data that was there.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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