Problem with Pasting to Next Available Row

toddncar

New Member
Joined
Apr 27, 2011
Messages
3
Hi all,

Being new to VBA, I am struggling with pasting data to the next available row in a separate worksheet.


What I want to do is use one Worksheet ("HAT") as a form for people to enter data. Using a macro, I then want this data transferred into another Worksheet ("Data Sheet"). My problem is setting up the macro so that it does not overwrite information that is already in a row of the Data Sheet, instead, copies the data into the next available blank row in the Data Sheet whenever the macro is run.

This is what I have so far for one cell of data to be transferred:
Sheets("HAT").Select
Range("B5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Data Sheet").Select
Range("C2").Select
ActiveSheet.Paste

My guess is that it involves- "NextRow" or "Offset", though despite aimlessly trying using other suggestions on the web, I have not been successful.

Appreciate any comments/ solutions for this.

Cheers
toddncar
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try something like this...
Code:
Sheets("Data Sheet").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = _
    Sheets("HAT").Range("B5").Value
 
Upvote 0
Thanks AlphaFrog,

When I enter this, I come up with the error message at ("B5")

"Compile Error

Invalid outside procedure"

Any thoughts on how to rectify this?

Cheers

 
Upvote 0
This worked for me.

Code:
Sub Macro1()

    Sheets("[COLOR="Red"]Data Sheet[/COLOR]").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = _
        Sheets("[COLOR="Red"]HAT[/COLOR]").Range("B5").Value

End Sub

Make sure you have two sheets named exactly as in the code; "Data Sheet" and "Hat".
 
Upvote 0
Thanks again, AlphaFrog

You have solved the problem! I had to copy and paste the sheets into a new workbook as said it could not operate in "Break mode".

All seems to work now.

Much appreciated for your quick response.
Toddncar
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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