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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
173
Would help to actually see the data you are working with and perhaps an example of what you are trying to do.
 

M Mueller

New Member
Joined
May 5, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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: 5
  • Macro 2.PNG
    Macro 2.PNG
    8.1 KB · Views: 5

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
173
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
 

Forum statistics

Threads
1,136,729
Messages
5,677,407
Members
419,691
Latest member
jlk3208

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
Top