VBA to search for calculated date within a row and then add a column after the cell is found

M Mueller

New Member
Joined
May 5, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I'm very new to using VBA as most of my skill in excel is just formula writing, so bear with me here:

What I'm trying to do is write a macro that will go to a specific sheet in my workboo - let's call it "weekly cash flow" - and then search in the same row every time (row 3) for a pre calculated date on a different tab - let's call this one "inputs". Once it finds the date within the row, I want to add a column after it. The pre-calculated date will always be in the same cell on the "inputs" tab, cell A5.

I've attempted to string together some code by do different internet searches and recording myself but I don't think I'm really getting anywhere.

Any help would be very appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Would help to actually see the data you are working with and perhaps an example of what you are trying to do.
 
Upvote 0
Would help to actually see the data you are working with and perhaps an example of what you are trying to do.
Sure - hopefully this helps:

In the image "Macro 1" attached, is a view of the "weekly cash flow" tab I mentioned above. I've circled April, 30, 2021 because that is the date that I want the macro to find. In the image "Macro 2" you will see the "inputs tab where I've pre-calculated the prior week ended date. That is the cell I want the macro to reference when running it's search.

I would then like to insert a new column after column OY o(r whichever column it finds the match in going forward) in the "weekly cash flow" tab.

Does that make sense?
 

Attachments

  • Macro 1.PNG
    Macro 1.PNG
    19 KB · Views: 8
  • Macro 2.PNG
    Macro 2.PNG
    8.1 KB · Views: 8
Upvote 0
This can will require some VBA programming.

First you have to compute the appropriate dates and then it's relatively easy to search thru and adding the appropriate figures to the appropriate totals.

Do I understand what your problem is? It's relatively easy to do, but before I spend the time on it, I want to be sure I understand what you want. And is all you want the 2 prior weeks.
And where do you want the total columns to appear: on the same sheet or maybe keep a log sheet with totals going back to some beginning date?

Mac
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,804
Members
448,990
Latest member
rohitsomani

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