Find and Replace using VLOOKUP function

Nidhi_

New Member
Joined
Mar 6, 2015
Messages
1
Hello,

A range of cells in my workbook are linked to another workbook. I want to update this link (which is nested in an IF function) every month from E.g. update from

'I:\HSD\SD\PE\SA\IY\IYM 2014-15\IYM from SA\Social Assistance\DECEMBER\[SASSA 2014-15 IYM DECEMBER 2014.xlsm

to

''I:\HSD\SD\PE\SA\IY\IYM 2014-15\IYM from SA\Social Assistance\JANUARY\[SASSA 2014-15 IYM JANUARY 2014.xlsm

Basically, change 'DECEMBER' to 'JANUARY' to 'FEBRUARY' so on and so forth as each month goes by.

Now I can run a basic Find and replace function macro to automatically update from a given month to the enxt, but to automate this process I would like to run a macro which performs the function as below which replaces the data link with the name of the previous month with that of the current month:


' Macro3 Macro
'


'
Range("DS7:ED19").Select
Range("ED7").Activate
Selection.Replace What:="=VLOOKUP(MonthNo.-1,Dashboard!S3:T14,2,FALSE)", Replacement:="=VLOOKUP(MonthNo.,Dashboard!S3:T14,2,FALSE)", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub


This doesn't work. Could someone please help me understand how to use the VLOOKUP function with the Find and replace function in VBA?

Thank you!
Regards,
Nidhi
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
i dont know how to be in VBA, so this may not help - but you could use an indirect() to pickup the month
depends on how that month changes and how you want to generate
you could simply type the month into a cell and it would update all the formulas
something like
indirect( ''I:\HSD\SD\PE\SA\IY\IYM 2014-15\IYM from SA\Social Assistance\"&CELL WITH MONTH IN&"\[SASSA 2014-15 IYM JANUARY 2014.xlsm"
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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