VBA Beginner Question

BradL11

New Member
Joined
Aug 26, 2019
Messages
2
Hi all - I imagine this is very elementary but I can't seem to get it right. I'm very experienced with Excel but very new to using VBA. Appreciate all help: I have a table called Table1. I would like to copy from another worksheet on the row below the final row of the table. The macro recorder uses a static cell address that I would like to replace with a formula. Here is what I tried:

Code:
  Selection.Copy    Sheets("TS").Select
    Range("B4").Select
    Selection.End(xlDown).Activate
    Range(ActiveCell.Offset(-1, 0)).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.End(xlDown).Select

Thank you in advance for the help!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
It looks likethis is what you want


See if this will work for you.

Code:
Selection.Copy    
Sheets("TS").Range("B4").End(xlDown).Offset(1).PasteSpecial Paste:=xlPasteValues

Your offset is going up a row. If you meant for it to go down one row then delete the minus sign. Never mind, I changed it because you said you wanted to pasete it below the last row of the table.
 
Last edited:
Upvote 0
Thank you, this worked perfectly! I may try to add a check at the beginning to delete today's data before running the procedure. But this is enough progress for one day! My first macro! :-)
 
Upvote 0
Thank you, this worked perfectly! I may try to add a check at the beginning to delete today's data before running the procedure. But this is enough progress for one day! My first macro! :-)

You're welcome,
regards, JLG
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,147
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