VBA automatic data input in macro

mjh000000

New Member
Joined
Aug 2, 2015
Messages
2
Hi,
I have written a macro to take a figure from one cell on one worksheet (cashing up sheet) and insert it in the last empty cell of a row in another worksheet. (daily figures sheet)
The problem I have is that it is erasing the figure immediately to the right of the cell where the data is being written to.

As I'm not very good with macros I'm not sure which part I need to edit or what I should edit it to.
The code is as follows.

Range("E34").Select
Selection.Copy

Sheets("Daily figures").Select

lMaxRows = Cells(Rows.Count, "AZ").End(xlUp).Row
Range("AZ" & lMaxRows + 1).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Sheets("Cashing-up Sheet").Select


This is exactly as the code is written. Can anyone identify the problem?
Thank you in advance.
Michael

edit - this is just the section of the code relating to this issue. The remainder of the code has been omitted for clarity.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi welcome to the board.

See if this code does what you want:

Code:
Sub Daily()
With Sheets("Daily figures")
    .Cells(.Cells(.Rows.Count, "AZ").End(xlUp).Row + 1, "AZ").Value = Sheets("Cashing-up Sheet").Range("E34").Value
End With


End Sub

Dave
 
Upvote 0
Hi Dave - thank you for the warm welcome.
Just implemented your code snippet and it works perfectly.
I'm very grateful for your help! Thank you!
:D
Michael
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,641
Members
449,325
Latest member
Hardey6ix

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