Macro to copy contents to next blank column

SirBarnabus

New Member
Joined
Jul 16, 2013
Messages
5
Dear Macro-gurus,

I have data entry on Sheet1. The user fills in the answers as they go, and at the bottom of the questionnaire, there is a button marked "Submit".

This button intends to trigger a macro, which copies all of the answers, pastes it to the next available column in Sheet2 and clears all of the answers in Sheet1.

On Sheet2, the same setup is used as Sheet1, but I also have a row for the data entry record number. I have had this at the top and bottom of the sheet, thinking that might be throwing the macro off, but moving it doesnt seem to help.

This is what I have so far:
Sub Submit()
'
' Submit Macro
'


'
Range("F6:F58").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Sheets("Sheet2").Select
ActiveWindow.SmallScroll Down:=0
Application.CutCopyMode = False
Selection.ClearContents
End Sub

To illustrate, say I have cells F6 - F58 filled with answers. By hitting submit, I want this to copy the cells to column D (cells D6 - D58) the first time, then E, then F and so on. I've googled endlessly, but can't seem to find the answer and/or don't know how to adjust the code so it will work for my example. Instead it seems to put the data in really random places - skipping down 50 rows or 10 columns across. I don't know if this has to do with resetting the macro, but while testing I have deleted the entered data (ie. cells D6-D58 are blank), yet this doesn't seem to help the issue either.

Any help would be greatly appreciated!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Ok an update: I figured out that it has to do with where my cursor is/the selected cell. Is there any way to not have this as a dependency? This seems rather user-sensitive..
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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