Copying cell values to next available row in a table

worl4125

New Member
Joined
Jan 7, 2016
Messages
15
Hello all,

I have a four column table (columns A through D) and I have four "data entry" cells (F2, G2, H2, and I2). What I want to do is this:
  1. enter my data in F2 through I2
  2. hit enter (or whatever button excel needs me to hit)
  3. have those values copied into the next available row in the table (A through D)
  4. have F2 through I2 cleared for the next data entry

I've gone through several of functions that I'm familiar but haven't been able to find a way to make this work. I suspect it is going to take some VBA to accomplish this and while I am a programmer, I am completely unfamiliar with VBA.

Can anyone offer any help with this?
Thanks in advance.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
in a helper cell have a count of non empty cells plus 1 = next available row - use a macro to copy F2 thru I2 to the next empty row - say helper is Z1 use cells(cells(1,26),1).select
 
Upvote 0
Ok; I've worked out a partially working solution...

Code:
sub ledgerInput()

    Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1,0).Value = Range("F2:I2").Value
    Range("F2:I2").ClearContents

End Sub

The problem is that it is only copying the data for the first cell. For example, the data in F2 is copied to the next empty cell in column A, like it should be; however the data from G2 to I2 isn't getting copied over to the corresponding cells in column B to D.
Any thoughts on what I'm missing?
 
Upvote 0
Is this on the same sheet or different sheets?
 
Upvote 0
As RasGhul has intimated you should explicitly state the sheet on all sheets when coding but based on the code you supplied maybe...
Code:
Sub ledgerInput()
    With Range("F2:I2")
        Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(.Rows.Count, .Columns.Count).Value = .Value
        .ClearContents
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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