How to copy data into next available column

AndyM90

New Member
Joined
Jul 25, 2014
Messages
47
Hi All,

I have a worksheet for which I want to automatically input data in daily. I am stuck on how to write a macro which selects the next blank cell in row 1 and inputs yesterdays date (DD/MM/YYYY)?

Secondly, I then want to be able to run a calculation (e.g. =SUMIFS(EURdata!F:F,EURdata!D:D,"EURO") and copy the answer into the next available cell in row 3 (in worksheet "EUR").

Any help would be greatly appreciated.

Thanks,

Andy
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi All, I have a worksheet for which I want to automatically input data in daily. I am stuck on how to write a macro which selects the next blank cell in row 1 and inputs yesterdays date (DD/MM/YYYY)? Secondly, I then want to be able to run a calculation (e.g. =SUMIFS(EURdata!F:F,EURdata!D:D,"EURO") and copy the answer into the next available cell in row 3 (in worksheet "EUR"). Any help would be greatly appreciated. Thanks, Andy
Hey Andy, What it looks like you are trying to do seems to be brief enough that you should be able to use the macro recorder. Although it seems like there is more to it than what you say based on trying to select the next blank cell. Most of what you can do can be accomplished without the macro which will free the macro up to just copy it into your data page. Before you do that you want to either in a test sheet of your workbook or on some graph paper decide in which cells you want what values. I have manipulated the date in several worksheets that I have prepared. If you just want to have yesterdays date already in a cell that would be:
Code:
 =(TODAY())-1
This takes today's date and subtracts one day from it. Beyond that you just need to format the cell to get the information to display as DD/MM/YYYY. You seem to have the other formula finished so plug that into a cell on your worksheet. Once you have done that then all you have to do is record a macro that copies that information from sheet1 into sheet2 in the specific locations that you want. Sort of using sheet 1 as your data entry while Sheet 2 holds all of your completed information. Once you have succesfully completed recording your macro and you have verified that there are no problems then you can link it to a button to make it easier. later Ty
 
Last edited:
Upvote 0
the recorder didn't help me out too much unfortunately, but with your help I have managed to piece a few pieces of code together to get the desired result:

Sheets("ABC").Activate
Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=WORKDAY(NOW(),-1)"

ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = "=SUMIFS....."

Thanks!
 
Upvote 0
the recorder didn't help me out too much unfortunately, but with your help I have managed to piece a few pieces of code together to get the desired result:

Code:
Sheets("ABC").Activate
Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=WORKDAY(NOW(),-1)"

ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = "=SUMIFS....."
Thanks!

Hey AndyM90,

Looks like some intense VBA/macro'ing there. I am suprised that you had to do as much, but glad that you found a solution.

later

Ty
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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